A lightweight .NET library that provides strongly-typed C# POCO classes for working with JSON-LD and Schema.org structured data.
$ dotnet add package FoxLearn.JsonLdFoxLearn.JsonLd is a lightweight .NET library that provides strongly-typed C# POCO classes for working with JSON-LD and Schema.org structured data. It enables easy serialization of semantic metadata in your web applications to boost SEO, enhance search engine visibility, and improve content discoverability.
Install via the .NET CLI:
dotnet add package FoxLearn.JsonLd
Or search for FoxLearn.JsonLd in the NuGet UI inside Visual Studio.
Schema.org is a collaborative community that creates, maintains, and promotes schemas for structured data on the Internet. Search engines like Google, Bing, Yandex, and Yahoo use this data to improve search listings with rich results such as:
Product ratings
Event details
Course listings
Breadcrumbs
Organization contact info
Websites
Structured data based on Schema.org can be embedded in the section of HTML pages to enable search engines to display rich, enhanced results. For example, Google may show extended metadata about your website directly in search results when structured data is present.
Example:
To include structured data in an HTML page, you can use a <script> tag with the MIME type application/ld+json.
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"url": "https://foxlearn.com",
"name": "FoxLearn",
"contactPoint": {
"@type": "ContactPoint",
"telephone": "+1-400-444-1711",
"contactType": "Customer service"
}
}
</script>
This allows search engines like Google to better understand your content and display enhanced search results accordingly.
✅ Basic Example: Organization
using FoxLearn.JsonLd;
using FoxLearn.JsonLd.Schema;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Serialization;
var org = new Organization()
{
Name = "FoxLearn",
Url = new Uri("https://foxlearn.com"),
LegalName = "FoxLearn",
Logo = new Uri("https://foxlearn.com/img/logo.png"),
Description = "Welcome to foxlearn.com! This site is a blog about everything that matters in the world of programming.",
ContactPoint = new List<ContactPoint>()
{
new ContactPoint() { ContactType = "Customer Service", Name = "Tan Lee", Email = "example@gmail.com"}
},
Founder = new List<IPerson>()
{
new Person() { Name = "Tan Lee"}
},
FoundingDate = new Date(2016, 01, 01),
Email = "example@gmail.com",
};
string json = JsonLdSerializer.Serialize(org);
Console.WriteLine(json);
Embed in your Razor view:
@Html.Raw(json)
This outputs:
{
"@type": "Organization",
"email": "example@gmail.com",
"founder": {
"@type": "Person",
"name": "Tan Lee"
},
"foundingDate": "2016-01-01",
"legalName": "FoxLearn",
"contactPoint": {
"@type": "ContactPoint",
"email": "example@gmail.com",
"contactType": "Customer Service",
"name": "Tan Lee"
},
"logo": "https://foxlearn.com/img/logo.png",
"url": "https://foxlearn.com",
"name": "FoxLearn",
"description": "Welcome to foxlearn.com! This site is a blog about everything that matters in the world of programming."
}
Here's a more complex example using SchemaRoot to generate structured data for a full web page including images, breadcrumbs, and actions.
var root = new SchemaRoot();
var page = new WebPage()
{
Id = "https://foxlearn.com/course/asp-net-core-tutorials/",
Url = new Uri("https://foxlearn.com/course/asp-net-core-tutorials/"),
Name = "ASP.NET Core Tutorials For Beginners",
IsPartOf = new WebSite()
{
Id = "https://foxlearn.com/#website"
},
PrimaryImageOfPage = new ImageObject()
{
Id = "https://foxlearn.com/course/asp-net-core-tutorials/#primaryimage"
},
Image = new ImageObject()
{
Id = "https://foxlearn.com/course/asp-net-core-tutorials/#primaryimage"
},
ThumbnailUrl = new Uri("https://foxlearn.com/wp-content/uploads/2025/01/ASP.NET-Core-Tutorials-1.png"),
DatePublished = new Date("2025-01-12T04:04:22+00:00"),
Description = "These ASP.NET Core Tutorials are designed for beginners as well as professionals developers who want to learn ASP.NET Core.",
Breadcrumb = new BreadcrumbList()
{
Id = "https://foxlearn.com/course/asp-net-core-tutorials/#breadcrumb"
},
InLanguage = "en-US",
PotentialAction = new ReactAction()
{
Target = new Uri("https://foxlearn.com/course/asp-net-core-tutorials/")
}
};
root.Graph.Add(page);
ImageObject image = new ImageObject()
{
Id = "https://foxlearn.com/course/asp-net-core-tutorials/#primaryimage",
Url = new Uri("https://foxlearn.com/wp-content/uploads/2025/01/ASP.NET-Core-Tutorials-1.png"),
ContentUrl = new Uri("https://foxlearn.com/wp-content/uploads/2025/01/ASP.NET-Core-Tutorials-1.png"),
InLanguage = "en-US",
Width = 908,
Height = 203,
Caption = "ASP.NET Core Tutorials For Beginners and Professionals"
};
root.Graph.Add(image);
BreadcrumbList breadcrumb = new BreadcrumbList()
{
Id = "https://foxlearn.com/course/asp-net-core-tutorials/#breadcrumb",
ItemListElement = new[]
{
new ListItem() { Position = 1, Name = "Home", Item = new Uri("https://foxlearn.com") },
new ListItem() { Position = 2, Name = "Courses", Item = new Uri("https://foxlearn.com/courses/") },
new ListItem() { Position = 3, Name = "ASP.NET Core Tutorials For Beginners and Professionals" },
}
};
root.Graph.Add(breadcrumb);
WebSite webSite = new WebSite()
{
Id = "https://foxlearn.com/#website",
Url = new Uri("https://foxlearn.com"),
Name = "FoxLearn",
InLanguage = "en-US",
Publisher = new Person()
{
Id = "https://foxlearn.com/#/schema/person/072a2d877405716353aa607e372bc216"
},
PotentialAction = new SearchAction()
{
Target = new EntryPoint()
{
UrlTemplate = "https://foxlearn.com/post/search/?q={search_term_string}"
},
QueryInput = new PropertyValueSpecification()
{
ValueRequired = true,
ValueName = "search_term_string"
}
}
};
root.Graph.Add(webSite);
string json = JsonLdSerializer.Serialize(root);
Console.WriteLine(json);
Better search performance: Appear in Google's rich cards and knowledge panels.
Higher click-through rates: Enhanced listings draw more attention.
Semantic clarity: Improve how your content is interpreted by AI tools and bots.
Clean, reusable code: Avoid manual JSON construction and validation.
This project is licensed under the MIT License. Free for personal and commercial use.