Skip to main content
When a user scans search results, the short block of text beneath each title — the snippet — is often what determines whether they click. The Custom Search JSON API gives you two versions of this text for every result: a clean plain-text variant and an HTML-annotated variant with query terms highlighted. Understanding both helps you render polished, accessible results in any context.

What Is a Snippet?

A snippet is a short excerpt from the matching page’s content, selected by Google’s indexing systems to best represent how the page relates to the search query. Google constructs snippets dynamically for each query — the same page can yield different snippets for different search terms. Snippets are typically 150–300 characters long, though the exact length varies.
Snippets are generated by Google at index time and query time. You cannot set or override them through the API. You can, however, influence which part of a page is excerpted by using the exactTerms parameter (see below).

The Two Snippet Fields

Each result item contains two snippet fields that carry the same underlying text in different formats.
string
The plain-text version of the excerpt. All HTML tags are stripped, and special characters are decoded. Use this field when rendering results in non-HTML environments (terminal output, native mobile apps, plain-text emails, or when you want to apply your own formatting).Example value:
string
The HTML-annotated version of the excerpt. Query terms that match words in the snippet are wrapped in <b> tags. Line breaks within the snippet are represented as <br> tags. Certain special characters and hyphens may be encoded as HTML entities (e.g., &#8209; for a non-breaking hyphen).Use this field when rendering results inside an HTML page. Drop it into your template and the browser will render bold highlights automatically.Example value:

Plain Text vs. HTML: Side-by-Side

Use this when:
  • Rendering in a native app or terminal
  • Passing the text to an LLM or downstream NLP pipeline
  • Building plain-text email digests
  • Applying your own custom highlight logic
Never render htmlSnippet content outside of a controlled HTML context without sanitizing it first. Although Google’s output is trusted, treat it as you would any third-party HTML: strip unexpected tags or run it through a sanitizer library before injecting it into the DOM.

Snippet Length

Google controls snippet length based on its analysis of the page and query. You cannot specify an exact character count through the API. In practice:
  • Typical range: 150–300 characters of visible text
  • Structured pages (those with schema.org markup or <meta name="description"> tags) may yield shorter, more precise snippets drawn from that metadata
  • Long-form articles often yield longer excerpts pulled from body text near the first occurrence of the query terms
  • Ellipsis () at the start or end of a snippet indicates the excerpt was taken from the middle of the page

Influencing Snippet Content with exactTerms

While you cannot directly control snippet selection, you can steer Google toward a specific part of a page by adding the exactTerms parameter to your request. Google will only return results where the page contains that exact phrase, and will preferentially excerpt the portion of the page that contains it. Request example — find pages mentioning a specific release and excerpt that section:
Effect on snippets: When exactTerms is set, Google is more likely to excerpt the sentence or paragraph containing that exact phrase, giving you a snippet focused on the topic you care about rather than a generic page introduction.
Combine exactTerms with siteSearch to find and excerpt specific information from a known domain. For example, to get a snippet focused on pricing from a vendor’s site:

Rendering Snippets: Code Examples


Snippet Field Reference Summary

string
Plain-text excerpt from the result page. Query terms are not marked up. Safe to use in any rendering context without sanitization.
string
HTML-encoded excerpt. Query terms are wrapped in <b> tags. Line breaks are <br> tags. Render only inside trusted HTML contexts, or sanitize before use.

Common Questions

No. Snippet length is determined entirely by Google’s indexing and ranking systems. There is no API parameter to request a longer or shorter snippet. If you need more page content, consider fetching the page directly and extracting text server-side.
Google may select a snippet from a part of the page it considers more representative of the overall content, even if your query terms appear elsewhere. Adding exactTerms with a specific phrase can help anchor the snippet to a relevant section.
The htmlSnippet field is always present when snippet is present — they derive from the same underlying data. If you see an empty string, the indexed page had insufficient text content for Google to generate an excerpt. This is uncommon but can occur for pages that are primarily images, PDFs, or heavily JavaScript-rendered without server-side text.
Not necessarily. Google may use the page’s <meta name="description"> content as the snippet, but it can also generate the snippet from any text on the page if it believes body text better matches the query. Structured data and meta descriptions increase the likelihood that your preferred text is used, but there is no guarantee.