Create Structured Markup with JSON-LD

JSON-LD is a way of annotating your web pages with structured data. It stands for JavaScript Object Notation for Linked Data. Google can provide enhanced search results based on the supplied data. In addition it describes the structure of the data on your web page.

Examples of Structured Data

  • Business
  • Person
  • Page
  • Product
  • Opening Hours
  • Event

The markup for JSON-LD is described on Here you can see all of the types that are available for marking up your webpage. However there is a nuget package that you can reference in your C# code to generate the JSON-LD for you.


Schema.Net is a nuget package designed by RehanSaeed. It turns the definitions into C# POCO classes.

JSON-LD Person

The example below is a LINQPad script. I have added to the query the Schema.Net nuget package.

The Person object defines who the person is and has details about me to enhance the search results. I first create a new instance of that object and then start adding properties to it. The SameAs allows google to link other social accounts to me as a person.

Once the object is populated then I call ToHtmlEscapedString() and the JSON-LD is generated. I wrap the JSON with a Script tag and it is ready to use on my website.

In order to know what objects are available please view where you can see a list of al the structured data objects available

using System;
using Schema.NET;

void Main()
	var person = new Person
		Name = "Jonathan Purdom",
		Email = "",
		Gender = Schema.NET.GenderType.Male,
		Address = new PostalAddress {
			StreetAddress = "Harwood Road",
			AddressLocality = "West Sussex",
			AddressRegion = "Littlehampton",
			PostalCode = "BN17 7AT"
		Url = new Uri(""),
		SameAs = new OneOrMany<System.Uri>
			new System.Uri(""),
			new System.Uri("")

	Console.WriteLine("<script type=\"application/ld+json\">");


Here you can see the output of the script above. You can have multiple JSON-LD blocks in the header to describe different parts of the page and data.

<script type="application/ld+json">
{"@context":"","@type":"Person","name":"Jonathan Purdom","sameAs":["",""],"url":"","address":{"@type":"PostalAddress","addressLocality":"West Sussex","addressRegion":"Littlehampton","postalCode":"BN17 7AT","streetAddress":"Harwood Road"},"email":"","gender":""}

Article Links