Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Roslyn
  3. JsonSrcGen

JsonSrcGen

MITC#1.1.1

A high-performance JSON serialization library for .NET 5+ using C# source generators.

GitHubGitHub
151 stars5 forks0 contributors

What is JsonSrcGen?

JsonSrcGen is a JSON serialization library for .NET that uses C# source generators to create highly optimized serialization and deserialization code at compile time. It eliminates reflection overhead, providing faster performance and lower memory usage for applications that frequently handle JSON data.

Target Audience

.NET developers building high-performance applications, such as APIs, microservices, or data-intensive systems, who need efficient JSON serialization without runtime reflection penalties.

Value Proposition

Developers choose JsonSrcGen for its compile-time code generation, which offers superior performance over reflection-based JSON libraries, along with features like UTF8 support, custom converters, and fine-grained control over serialization behavior.

Overview

Json library that uses .NET 5 Source Generators

Use Cases

Best For

  • High-performance .NET APIs requiring fast JSON serialization
  • Microservices with strict latency and memory constraints
  • Applications processing large volumes of JSON data efficiently
  • Projects leveraging .NET 5+ source generator features
  • Scenarios where reflection-based JSON libraries are too slow
  • UTF8-based JSON handling for optimized byte operations

Not Ideal For

  • Projects targeting .NET Framework or .NET Core 3.1 and earlier, as JsonSrcGen requires .NET 5+
  • Applications needing dictionaries with non-string keys, since only string keys are supported
  • Teams prioritizing quick, reflection-based setup over compile-time optimization for JSON serialization
  • Scenarios requiring extensive dynamic type handling, as JsonSrcGen relies on compile-time code generation

Pros & Cons

Pros

Compile-Time Performance

Generates serialization code at compile time using .NET source generators, eliminating runtime reflection overhead for faster serialization and deserialization.

UTF8 Byte Efficiency

Supports UTF8 serialization via `ReadOnlySpan<byte>` methods like `ToJsonUtf8`, enabling low-memory, byte-level operations that optimize performance for high-throughput applications.

Fine-Grained Control

Offers attributes such as `[JsonIgnoreNull]` to skip null properties and `[JsonOptional]` to set defaults for missing JSON, allowing precise serialization behavior.

Object Reuse Boost

Enables object reuse in deserialization with the `JsonOptional` attribute, reducing allocations and providing significant performance gains for repeated operations.

Custom Converter Flexibility

Allows implementing `ICustomConverter<T>` with the `[CustomConverter]` attribute, giving developers control over custom type serialization logic.

Cons

Limited Dictionary Support

Only supports dictionaries with string keys, as stated in the README, which restricts use cases with complex or non-string key types.

Assembly-Level Boilerplate

Requires defining attributes like `[assembly: JsonArray]` at the assembly level for arrays, lists, and dictionaries, adding setup complexity and boilerplate code.

Steep Source Generator Learning Curve

Relies on .NET 5+ source generators, which can be unfamiliar to developers used to reflection-based libraries, and the attribute-based configuration is less intuitive.

No Backward Compatibility

Requires .NET 5 or later, limiting adoption in legacy projects or environments stuck on older .NET frameworks without migration efforts.

Frequently Asked Questions

Quick Stats

Stars151
Forks5
Contributors0
Open Issues1
Last commit14 days ago
CreatedSince 2020

Tags

#serialization-library#nuget#csharp#utf8#dotnet#json-serialization#csharp-sourcegenerator#source-generators#performance#compile-time

Built With

C
C++
.
.NET 5

Included in

Roslyn734
Auto-fetched 9 hours ago

Related Projects

StrongInjectStrongInject

compile time dependency injection for .NET

Stars867
Forks25
Last commit1 year ago
Generator.EqualsGenerator.Equals

A source code generator for automatically implementing IEquatable<T> using only attributes.

Stars192
Forks24
Last commit8 days ago
StructPackerStructPacker

Low-level, lightweight and performance-focused serializer for C# struct types that uses Source Generators technology.

Stars83
Forks7
Last commit4 years ago
WrapperValueObjectWrapperValueObject

A .NET source generator for creating simple value objects wrapping primitive types.

Stars52
Forks3
Last commit3 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub