Skip to Content

Rich Snippets and the Rise of JSON-LD

[Google, Community]
In a previous blog post, Randy discussed the fact that Google has pulled the plug on the authorship program as a means for website authors to specify additional information about themselves and have it appear in Google search results. This post explores one of the newer options available for providing this kind of information to Google and other search engines in order to enhance the appearance and relevance of a website's search results.

What are Rich Snippets?

Burlington Upcoming Events Gabriel Iglesias

Google uses the term Snippet for the text that appears beneath a search result to provide additional information about the page. Traditionally, this had been a simple piece of a text that was taken from the content of the page or perhaps the meta description tag. A few years ago, Google introduced the concept of Rich Snippets, which allowed webmasters more control of what information appeared beneath their listing in the search results. Rich Snippets went beyond the simple text description, perhaps providing a list of upcoming events if the search result was for a Concert Venue or a list of Locations if it was for a brick and mortar business. In order to help search engines collect the data it needs from your website so that they can give users additional information, your website needs to provide the data (Event title, location, date, etc.) in a specific format that is easy for machines to read. There are a number of different formats which you can use for this purpose, and this blog post is about a relatively new option called JSON-LD.

What is JSON?

To understand what JSON-LD is, lets break down the term into its component parts: JSON and LD and examine them individually. So what is JSON? JSON is a lightweight format for representing any kind of data. Here is an example of some JSON which represents a person.
{
    first_name: "Jerry",
    last_name: "Seinfeld",
    occupation: "Comedian",
    date_of_birth: "1954-04-29"
}
As you can see, JSON is fairly easy to read for humans as well as machines. In this example we have a single person who has some properties (a First Name, a Last Name, an Occupation and a Date of Birth).

What is JSON-LD?

The LD in JSON-LD stands for Linked Data. In this context, the word linked can be understood to mean related. So Linked Data is data that is related to other data. For example, if your data is a list of concerts then each concert has at least one musician which is playing at that concert. The data about the concert (date, location, etc.) is linked to the data about the musicians (the name of the band or artist, the URL of their website, etc.). JSON-LD is a set of rules for how to structure your JSON which makes it easy for machines to understand relationships between different pieces of data. JSON-LD gives you a specific way in which to represent different types of data (e.g. events, bands, locations) and the relationships between them (this band is playing at this event, this event is happening at this location). Here is some example JSON-LD which describes the band Primus and includes an event where they are performing and the location of that event, which happens to be the Flynn Center here in Chittenden County, Vermont.
{
  "@context": "http://schema.org",
  "@type": "MusicGroup",
  "name": "Primus",
  "event": [
    {
      "@type": "Event",
      "startDate": "2014-10-06",
      "name": "Primus & The Chocolate Factory",
      "location": {
        "@type": "LocalBusiness",
        "name": "The Flynn Center",
        "url": "http://www.flyncenter.org",
        "address": {
            "@type": "PostalAddress",
            "addressLocality": "Burlington",
            "addressRegion": "VT",
            "streetAddress": "153 Main Street"
        }
      }
    }
  ]
}
The above JSON-LD describes a MusicGroup named Primus and indicates that they are playing an Event  on October 10, 2014 at the Location of the LocalBusiness named the Flynn Center which can be found at the PostalAddress of 153 Main Street, Burlington, VT. By describing your data in this structured and standardized JSON-LD format, your website helps Google's search engine to clearly understand the relationships between your data. In turn, this gives Google the information it needs to enhance your search results by including this list of events as a Rich Snippet when displaying your website in its search results.

Why JSON-LD?

You can choose from multiple formats when providing Google with data for its Rich Snippets, including JSON-LD, Microdata and RDFa, so why would you use JSON-LD in particular? Here are some of the benefits it has over the other data formats.
  1. JSON-LD is easy for programmers to produce regardless of their chosen programming language because most languages provide facilities for working with JSON and because there are libraries for generating JSON-LD for a number of popular languages.
  2. The JSON format originated with the Javascript programming language, which is used on almost every website today, so the syntax is familiar to many developers.
  3. Unlike Microdata and RDFa, using JSON-LD separates your data from your HTML structure, which allows you to provide data as JSON-LD without having to change your HTML structure. It also makes it easier to provide your data to Google without having any effect on what users of your website see.
Additionally, and this last item is little more subjective than the advantages listed above, because of its lightweight nature many people find JSON-LD easier to read and understand than formats like Microdata and RDFa. You can see an example below of how you would represent a Person using Microdata compared to how the same data would appear in JSON-LD.

Microdata

<div itemscope itemtype="http://schema.org/Person">
  <span itemprop="name">Jerry Seinfeld</span>
  <span itemprop="jobTitle">Comedian</span>
  <a href="mailto:jerry@seinfeld.com" itemprop="email">
    jerry@seinfeld.com
  </a>
</div>

JSON-LD

{
  "@context": "http://schema.org",
  "@type": "Person",
  "name": "Jerry Seinfeld",
  "email": "mailto:jerry@seinfeld.com",
  "jobTitle": "Comedian",
}
Both Microdata and RDFa use your HTML to provide the data that Google needs for Rich Snippets. HTML syntax is very similar to XML (which is another data format) and although one format is not inherently better than another, the rise in popularity of JSON in recent years speaks to the relative convenience and readability of the format. The figure below shows a comparison below of Google searches for XML, RDFa, Microdata and JSON.

XML vs JSON vs RDFa vs Microdata

With JSON's lightweight format and readability swiftly gaining popularity compared to the more verbose and harder to read XML family of data formats, it seems likely that JSON-LD is poised to become a popular alternative to RDFa and Microdata.