What is JSON-LD?
JSON-LD stands for JavaScript Object Notation for Linked Data, which consists of multi-dimensional arrays (think: list of attribute-value pairs).
It is an implementation format for structuring data analogous to Microdata and RDFa. Typically, in terms of SEO, JSON-LD is implemented leveraging the Schema.org vocabulary, a joint effort by Google, Bing, Yahoo!, and Yandex in 2011 to create a unified structured data vocabulary for the web. (However, Bing and other search engines have not officially stated their support of JSON-LD implementations of Schema.org.)
JSON-LD is considered to be simpler to implement, due to the ability to simply paste the markup within the HTML document, versus having to wrap the markup around HTML elements (as one would do with Microdata).
What does JSON-LD do?
JSON-LD annotates elements on a page, structuring the data, which can then be used by search engines to disambiguate elements and establish facts surrounding entities, which is then associated with creating a more organized, better web overall.
Where in the HTML (for a webpage) does JSON-LD live?
Google recommends adding JSON-LD to the <head> section of the HTML document; however, it’s okay if the JSON-LD is within the <body> section. Google can also grasp dynamically generated tags in the DOM.
JSON-LD breakdown
The immutable tags (Think: You don’t need to memorize these, just copy/paste)
<script type="application/ld+json"> {
When you see JSON-LD, the first think you should always see is a <script> tag. The <script> tag with a type attribute says, “Hey browser, I’m calling the JavaScript that contains JSON-LD.”
Pro Tip: Close every tag you open when you open it. Think: The salt goes with the pepper, and opening braces come with a closing brace. |
Note: If your JSON-LD isn’t in the curly braces, it isn’t being parsed (i.e., curl it up).
"@context": "https://schema.org",
The second element that retains a permanent place in JSON-LD markup is the @context with the value of https://schema.org. The @context says, “Hey browser, this is the vocabulary I’m referencing. You can find it at https://schema.org.” The benefit for an SEO is that we get to use any of the item types and item properties that Schema.org defines.
Additionally, you’re probably noticing that cute, eyelash-like comma at the end of the statement. Commas mean “There’s more. Don’t stop parsing the data.”
Pro Tip: Mind your commas (and always check in Google’s Structured Data Testing Tool). Commas are a traditional sore-spot for many programmers and JSON-LD offers no solace here. Missed commas mean invalid markup. |
"@Type": "…",
The final element in the JSON-LD Schema copy/paste squad is the @type specification (after the colon, it becomes all data annotation). @type specifies the item type being marked up. You can find a comprehensive list of all item types at: https://schema.org/docs/full.html.
In the example below, the @type says, “Hey, I’m using the Person item type (You can find it at https://schema.org/Person).” Indeed, if you type the URL into the browser, the item type’s documentation and technical specifications should appear, including any item properties (and often some example use cases).
@type for nesting: When you use a nested item type, you’re going to need to nest another @type (this is particularly important to understanding product and breadcrumb markups).
Attribute-value pairs
The next step is to annotate information about the item type. You can find item properties within the item type’s Schema.org page.
In terms of the syntax of JSON-LD, there are two important elements for each item property:
- Item Property – This comes from the Schema.org vocabulary and should always be in double straight quotation marks (it may sound pedantic here, but for real the curly and single quotation marks are different and will interfere with validation), and must belong to the properties allowed within the item type (as specified within Schema.org).
- Value – You insert your value here for the property. It’s vital the value aligns with the property and is singular (i.e., each value must be annotated separately. In the situation of multiple values for an item property, use square brackets). Strings (characters) and URLs need the "double straight quotation marks." Numbers, integers, floats, or doubles (for the programming inclined) alone don’t need quotation marks, but it’s also okay to put them into quotations (this just means they’ll be considered a string data type).
Square brackets
Square brackets exist for situations where there are multiple values for an item property. A common use is leveraging the sameAs item property as using [square brackets] for listing multiple social media platforms.
The square brackets below are saying, “There are multiple values for this item type; Jason Derulo has two given names.”
Note: There is no comma after the last element in the square brackets. This indicates that there is no more information within the square brackets.
Nesting
Nesting is defined as where information is organized in layers, or where objects contain other objects. The image of a nesting doll is a common analogy, where large dolls contain smaller dolls within them, as a relational data organization visual.
Nest is a vital aspect for accurately marking up Schema.org JSON-LD, because you’re going to have certain item properties that belong to item types that do not belong to others. For example, below we can see the item property "name" can refer to the event name, the name of the performer, and the name of the venue. The name of the performer and venue are both nested.
Match the correct name item properties to the appropriate item type:
Nesting in JSON-LD starts with the item property. Within the first item type (ex. Movie) you must first use the item property (ex. actor, director, image). That item property is identified and then we must open curly brackets with the new item type (as indicated by the "@type":) and attribute/value data.
JSON-LD nesting checklist:
- Must use the item property (specific to the item type)
- The value lives in curly braces
- You MUST identify the item type of that property
- Attribute/value properties must be included (typically there are requirements for what needs to be included)
- No comma before the closing curly bracket
- Comma after closing curly bracket if there are more item properties (if not, it’ll be followed by a curly brace)
Pro Tip: Indent nested elements for readability. |
Common use: Within the Product item type markup, Price is nested within an Offer item type and ratings are also nested!
Pitfalls
If your markup isn’t validating in Google’s Structured Data Testing Tool and you’re unsure of what’s going on, check this list. Below are some major pitfalls in creating JSON-LD structured data markup.
- Syntax
- “” are not the same as "" (curly versus straight; the struggle is real)
- Mind your commas
- Especially note the Structured Data Testing Tool’s little red “x” on the left-hand rail. Oftentimes the “x” will appear below a missing or extraneous comma
- Vocabulary
- Pay attention to required/allowed properties within each Schema.org’s item type specification page
- Always check in Google’s Structured Data Testing Tool
- Policy Violation
- All annotated information must be on the page; adding information that is not on the page will likely not show in search results and is against Google guidelines
- It is also against the rules to engage in manipulative practices (not a pitfall I’m worried about for you!)
- Check/review Google’s Structured Data Policies
- Microsoft (sorry Bill, I’m still a huge fan!)
- Copy/paste from Word/Excel can create issues (added quotation marks, added style formatting)
- Microsoft switches "" to “”
- Solution: use an HTML editor
Process of adding JSON-LD to site
The process of creating JSON-LD structured data markup is dependent on one’s comfort with the Schema.org vocabulary and the JSON-LD syntax. Below outlines a process for a person newer to JSON-LD and Schema.org to create markups, while developing a deeper understanding of the vocabulary.
- Mentally answer:
- What do you want to mark up?
- Goal: Determine that you can mark up the content with the Schema.org vocabulary. Some things may make sense conceptually, but are not available within the vocabulary.
- Why do you want to mark it up?
- Goal: Determine whether there is a business case, or perhaps you’re looking to experiment. You don’t want to mark content up just for the sake of marking them up; you want to mark up content that will help search engines understand the most vital information on your page and maximize your ability to demonstrate that you are the best resource for users.
- Look for resources on markups Google is supporting, how they are using them, and examples.
- What do you want to mark up?
- If you’re using a markup that Google is explicitly using (i.e., resources on Google), open the specific documentation page and any relevant examples
- Don’t feel like you have to create JSON-LD markup from scratch. Use Google’s examples to reverse-engineer your markups. (This isn’t to take away from your understanding of JSON-LD and the Schema.org vocabulary; however, no need to reinvent the wheel! #efficiency ☺).
- Open up the Schema.org item type page
- Especially when you’re starting off with Schema.org, skimming the Schema.org technical documentation page to get a gist of what the item type entails, how many sites are using this markup, and its various properties can facilitate a better understanding as you continue along your structured data journey. After a while, this step might become necessary only when attempting a new markup or looking for a corner case.
- Copy/paste the immutable elements (i.e., from <script to "@type":)
- Save yourself time and mental energy. Another possibility here is to reverse-engineer an existing example, in which case these element should be present.
- Occasionally in Google’s examples they’ll leave out the <script> tags, but please note that they are vital for the content within the HTML document. JavaScript can’t be parsed without <script> tags.
- Add desired item type you’re interested in marking up as the value of @type:
- List item properties and values
- This step doesn’t require syntax and is more of a mental organization exercise. Concentrate on what you want to markup — don’t worry about the nitty-gritty yet. Basically, you want to get out your thoughts before you start diving into the "how."
- Often times you may have ideas about what you want to mark up, but may not necessarily know if it’s possible within the vocabulary or how it’s nested.
- Add JSON-LD syntax, nesting where required/appropriate
- The nitty-gritty step where you put everything into the syntax, nest it, and put markup together.
- Test with the Structured Data Testing Tool
- Confirm that the structured data is validating and that all item properties are listed and accurate.
- Determine strategy for adding to the webpage
- You can simply paste one markup into the <head> section or if a more dynamic/templated solution is applicable. Work with your dev team to get information on the page.
- Consider whether reference IDs can help supplement your markup (here's a great Moz article on great Moz article on ItemID and ItemRef here and great Moz article on ItemID and ItemRef here here)
What have your experiences been so far with JSON-LD? Please share your questions and thoughts in the comments!
Hey Alexis,
Seing as its mostly just Google now that likes JSON-LD (and Google is where its at for now) - I would suggest that you try adding the scripts from Google Tag Manager.
Easier to add to begin with (especially for non-devs), and easier to update when testing tool says to add more in your markup (schema.org library ever evolving). And it also has a couple of other huge benefits:
This means that you can replace static content with variables, and find a trigger that fits your needs - which allows for a dynamic JSON-LD autopopulating Schema markup (and also updating it automagically as content gets updated).
Quick how-to add static JSON-LD for ie. frontpage of example.com:
Simplified dynamic JSON-LD Schema markup setup:
Works with just about anything imaginable that you want to add schema markups to.
Love it. Thanks for reading and providing useful tips!
Agree. One of the best benefits of JSON-LD is that it can be added by GTM.
Wow - another great use from GTM. Thank's so much for the headsup Hans.
I love JSON-LD, and so i've shared this article with my colleagues who wonder why I keep on talking about 'Jason' and how great 'Jason', and how 'Jason' might help our SEO. Great tips here, and the level/tone just right for the beginners. Thanks a lot :)
Jason is going to get a promotion - for sure. ;)
Thanks for the guide. I've got a couple questions for you:
Thanks!
Thanks for reading Caleb!
Thanks Alexis for this article. I was waiting to read something really interesting on JSON. It's really great and its importance in internal structure is growing.
Thank you!
Finally, a simple post about this tool and many useful applications. Thank you.
Thank you!
You have added JSON-LD in basic SEO but it should be in advance SEO section. A good read for me and I am trying to understand why we should use this even schema structural data also determine to Google about your different format of your content. Oh, I see that will remove un nectary attribute and syntax.
But I must say that article look like for tutorial for new users even for the nontechnical guy like me :) Nice sharing.
The basic/advanced categories are fairly muddled - https://gadgetopia.com/wp-content/uploads/images/pe...
However, I think this article does belong in "basic SEO". We're seeing structured data provide great results in rankings in our tests, and JSON-LD is THE way to implement it, and this article does a good job of explaining it, as you say. This is part of foundational SEO now.
Definitely becoming a core competency of any SEO's journey. Thanks Tom. Love the humility graph!
Hi Faisal!
Thank you for reading! Although there are many benefits of structured data; today, the greatest value is annotating high priority information on your pages. This informs search engines about what matters and can even get you a nice rich snippet!
Check out https://developers.google.com/search/docs/data-typ..., the Google team has worked really hard over to update their documentation on what structured data they are are currently using! They also have really great examples. :)
Warm regards,
Alex
I understand your points completely that google is now determining our site data through https://developers.google.com/search/docs/data-typ... it required to add json-ld by this we can stucturized our data and you can determine this.
Great guide. I've been using the automated services out there for a while now, so its good to understand the foundations of JSON. Thanks.
Really great post Alexis, especially the Pro Tips and Pitfalls. Those were the frosting on top of this delicious cake!
Thanks Jim!
Hello,
Do you need to spread the JSON script on all the web pages of the site ? Or just on the home ?
By exemple, i'm an organisation, do i need to include the script for organisation on all my webpages ?
Cheers.
Hi Adrien,
Thanks for read. You do not need to have it on all of you pages. I would prioritize Organization markup on your home page, since the home page is the most relevant for your organization. Then, if you feel that you have the time/resources, I would add it to any other relevant pages. If it's an option to include in a template- then do it, because you're only supporting search engines ability to understand the on-page content (and it really doesn't detract from site performance).
Google offers this advice - don't block pages in the robots.txt. This makes sense, because otherwise Google would able to crawl your markup. However, it also suggests (through saying "pages") that including multiple Organization markups is okay. This also makes sense, since structured data can only support search engines understanding of your content.
-Alexis
Hi Alexis,
This is a great read, one of the first articles available that actually goes through the process step by step, a sure fire resource for many technical SEO's the world over like myself recommend Schema mark-up for our clients.
Even with GTM as a way to implement Schema through Tagging, it is great to get the understanding of the structure in it's most basic form, and I agree 'Jason' is definitely getting a promotion!
Nice work and thanks again,
Kev
Thanks for reading Kev! +1 for #Jason!
A great article. There are many people who are unaware that this structured language is useful, but it is imperative to improve the SEO of your website.
If you manage Wordpress, there are plugins that configure it properly.
Personally I only select the tags that I most want to implement, because when I put them all, the website goes slower. I think it will be plugins.
Sure, I will try JSON-LD for my site. very deep information about JSON-LD & schema.
Thanks for sharing this, Alexis! Although this article is a bit advanced for me, I’ll definitely bookmark it for future reference.
How well does this work on mobile devices?
Great question - especially with the mobile-first indexing coming out.
The answer is - you want any structured data to be equivalent across devices (regardless of your mobile configuration).
Responsive makes that easy, but if you have separate sites by device - make sure the structured data is the same.
Great intro to JSON-LD Alexis.
I have found that JSON-LD can have the benefit over microdata that sometimes there may not be appropriate HTML to add the structured data to but with JSON-LD the data is all included in the document <head> so this problem is avoided.
This can be especially true for web applications where the majority of content is dynamically generated with JavaScript upon user interaction and not much text is present for search engines to analyse. Without the JSON-LD search engines wouldn't have much data to inform them what such pages are about but with it and the schema WebApplication type some more context can be provided.
I must say, i'm a fan of energy-efficient light bulbs used to mark the tips :)
Lol. Have to keep those moments of brilliance efficient. :)
Hi Alexis,
It is a great read. Not just for beginners but for experienced SEOs as well. A very detailed post with good examples. Specially "Jason" in JSON LD for the movie snippet. I have seen it appear for some item types but not for all. I think Google decides what to show and what not to show, even with the microdata or structured data is properly executed.
Very clever using all "Jasons" to talk about JSON-LD!
I'm grateful for such an easy-to-follow instructional article, as structured markup is something I'd really like to start pushing at our company. Some of it went over my head at this stage, but I'll be bookmarking for future reference!
Great work!
Thanks for reading. Feel free to comment with any questions! :)
Hi Alexis,
Nice article!
I've recently implemented JSON-LD on my own blog site ( https://cycling-jersey-collection.com/ ) before going ahead with a bigger project for our eCommerce site. I've still got some issues to resolve, but I'm 90% there!
I found that https://jsonld.com/ was a great, simple yet very effective resource for me during that process.
You've already mentioned the Structure Testing tool which is also invaluable.
Plenty of examples to read/use.
Kind Regards
Andy
Thanks for sharing Andy! Great tip! I'll have to check it out.
Hi Alexis,
thanks for a great post!
I have two questions regarding JSON-LD markup. How do you think:
1. Can we use JSON-LD and Microdata together on one page for the same entity? (and not be lowered in SERP for that)
e.g. for the 'Article'. reasons: (a) not wide support for JSON-LD yet. (b)and i've read an opinion that Microdata may be preferable because it written above the existing data, thus not spam.
2. Is it possible to describe linked entities as one via nesting?
say, we have Creative Work and Event defined as a different entities. Can we put an Event into Creative Work? e.g An article about an event, when such article is long enough to be considered as an Art work. In other words - How correctly inject Event markup with dates etc into parent Article?
reason - to 'hint' SE use it in rich snippet (start date, end date) along with article's description
Nobody has said it so far, so maybe I'm alone here, but I found the article difficult to understand, pretty unhelpful and badly linked (a link to a definition of multi-dimensional arrays doesn't help if one doesn't know what an array is in the first place ... and that destination page doesn't help because it starts with "Earlier in this tutorial....").
And if you don't understand multi-dimensional arrays, don't worry, just think "attribute-value pairs". Yeah, right.
The very second sentence says, "It is an implementation format for structuring data analogous to Microdata and RDFa. Typically, in terms of SEO, JSON-LD is implemented leveraging the Schema.org vocabulary,"
What's that in English? Or is a beginner meant to be already familiar with "implementation formats for structuring data" and "leveraging the schema.org vocabulary"?
Maybe the article works for some readers, but to call it "for beginners" is deceptive. It's far from a beginner guide to anything! Thumbs me down if you want to, but this is the first time I've made a critical comment about any post at Moz ... and this one was a waste of time for me.
Hi Alexis,
I found this article extremely helpful, but I have some questions regarding the use of Organization or Local Business markups.
I recently added a Local Business markup for our site and included some data that isn't explicitly stated on the home page.
My questions are:
1. Should I not include markup for information such as our business hours if they aren't listed on our homepage?
2. Should I include the Local Business markup on every page, or just my homepage?
I don't want to break the guidelines for this by accidentally marking up information which Google can see but not users.
Thank you so much.
Hi Robert!
Thanks for reading.
1. Don't add JSON-LD for any information that is not on the page. It's against Google's Quality guidelines ("For example, if the JSON-LD markup describes a performer, the HTML body should describe that same performer."). Changes are that they won't populate the information in a snippet.
2. I would start with adding the local markup on any local business pages (highest impact potential and most relevant to the page). You can markup all pages that include the local business and it will be good semantic markup; however, I would try to focus in on what the topic of the page is and make sure that is marked up.
-Alexis
Hi,
I added JSON-ld to my site and tested it in google testing tools correctly, but google rich snippets tools in Webmaster Tools and MOZ Bar dont recognize it!
I google my name and dont see any effect of structure data in SERP
Hi mos.6395,
Did you update it recently? Since GSC and Google's index can take a while to update.
Also, Google has prerogative on the snippets. I own a few small sites that's markup exists, but never generated snippets. That may seem discouraging at first, since the snippets have such a clear difference; however, the true heart of adding structured data is the ability to clarify important information.
Sometimes you can use a site: search operator and a high-intent query to see if the snippet exists.
I built A JSON LD generator a while ago and it's still available. https://www.jamesdflynn.com/json-ld-schema-generat...
Hopefully it makes life easier on some people having a hard time getting it to validate.