valyala/fastjson

Fast JSON parser and validator for Go. No custom structs, no code generation, no reflection

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 34 minutes ago
Added to GitGenius on March 25th, 2026
Created on May 28th, 2018
Open Issues & Pull Requests: 69 (+0)
Number of forks: 158
Total Stargazers: 2,464 (+0)
Total Subscribers: 26 (+0)

Issue Activity (beta)

Open issues: 30
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 1,446 days
Stale 30+ days: 30
Stale 90+ days: 30

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • question (9)
  • enhancement (3)
  • bug (2)

Most active issues this week

No issue events were indexed in the last 7 days.

Repository Insights (GitGenius)

Median issue/PR response: 13.0 days
Mean response time: 359.3 days
90th percentile: 1932.5 days
Tracked items: 7

Most active contributors

Sign in to see contributor activity.

Detailed Description

fastjson is a high-performance JSON parser and validator for Go that prioritizes speed and flexibility without requiring custom structs, code generation, or reflection. The library achieves parsing speeds up to 15 times faster than Go's standard encoding/json package, making it particularly suited for performance-critical applications like real-time bidding services and JSON-RPC implementations.

The core design philosophy of fastjson centers on parsing arbitrary JSON without imposing schema constraints. Unlike alternatives such as easyjson, the library does not require predefined struct definitions or code generation steps. This approach provides significant advantages when working with JSON data that lacks a fixed schema or when only a subset of fields needs to be accessed. The parser performs a single pass through the input JSON, which gives fastjson a performance edge over libraries like jsonparser and gjson when accessing multiple unrelated fields from the same document.

fastjson provides a straightforward API for JSON manipulation and extraction. The library includes methods for accessing specific fields through Value.Get operations, extracting portions of the original JSON with Value.Get(...).MarshalTo, and modifying parsed JSON using Del and Set functions. The parser validates JSON during the parsing process, unlike some competing libraries that skip validation. The library can handle arrays containing heterogeneous types, such as mixed integers, strings, nested arrays, and objects within a single array. When iterating over object items, fastjson preserves the original order from the input JSON through the Object.Visit method.

The library includes a Scanner for parsing streams of JSON values from strings and provides a ParserPool for efficient reuse of parser instances across multiple parsing operations. Performance optimization is facilitated through parser reuse, which reduces memory allocation overhead, and through strategic use of the Get methods to avoid redundant parsing of the same input.

Security considerations are built into fastjson's design. The parser will not crash or panic on specially crafted malicious input and instead returns errors for invalid JSON. Memory usage is bounded by the size of the input JSON, with the library requiring up to sizeof(Value) times the input length in bytes, allowing developers to limit maximum memory consumption by restricting input size.

The library does have notable limitations. References to objects returned by the Parser must be released before the next Parse call, and objects from Arena instances follow similar constraints. The parser cannot directly read from io.Reader interfaces. These restrictions require careful usage patterns to avoid improper program behavior.

According to GitGenius activity tracking, the repository shows median issue and pull request response latency of 312.3 hours across tracked items, with contributors including rleighton, folivoramao, and kpm. The repository maintains connections with other significant Go projects including the official golang/go repository, ClickHouse, and RagFlow, indicating its relevance within the broader Go ecosystem for JSON processing tasks.

fastjson
by
valyalavalyala/fastjson

Repository Details

Fetching additional details & charts...