{"id":17115661,"url":"https://github.com/annikacodes/rust-json-parsing-benchmarks","last_synced_at":"2025-07-30T22:02:06.718Z","repository":{"id":105882356,"uuid":"412241502","full_name":"AnnikaCodes/rust-json-parsing-benchmarks","owner":"AnnikaCodes","description":"A benchmark comparing seven different Rust JSON parsers!","archived":false,"fork":false,"pushed_at":"2021-10-01T18:49:15.000Z","size":23,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-25T00:15:01.474Z","etag":null,"topics":["benchmark","json","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AnnikaCodes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-09-30T22:02:32.000Z","updated_at":"2025-06-11T06:46:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"a682acd3-f44b-478f-9fe6-45f265ea2f07","html_url":"https://github.com/AnnikaCodes/rust-json-parsing-benchmarks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AnnikaCodes/rust-json-parsing-benchmarks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnnikaCodes%2Frust-json-parsing-benchmarks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnnikaCodes%2Frust-json-parsing-benchmarks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnnikaCodes%2Frust-json-parsing-benchmarks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnnikaCodes%2Frust-json-parsing-benchmarks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AnnikaCodes","download_url":"https://codeload.github.com/AnnikaCodes/rust-json-parsing-benchmarks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnnikaCodes%2Frust-json-parsing-benchmarks/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267948433,"owners_count":24170477,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmark","json","rust"],"created_at":"2024-10-14T17:45:47.664Z","updated_at":"2025-07-30T22:02:06.696Z","avatar_url":"https://github.com/AnnikaCodes.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust JSON parsing benchmarks\nThis project aims to provide benchmarks to show how various JSON-parsing libraries in the Rust programming language perform at various JSON-parsing tasks. It is only concerned with performance, and does not take into account other factors that you should consider when choosing a JSON parser (such as validation, RAM usage, code readability, and active maintainace).\n## Benchmark methodology\nThe following Rust libraries for JSON parsing were benchmarked:\n- [Serde JSON](https://crates.io/crates/serde_json)\n- [GJSON](https://crates.io/crates/gjson)\n- [A-JSON](https://crates.io/crates/ajson)\n- [json-rust](https://crates.io/crates/json)\n- [Pikkr](https://crates.io/crates/pikkr_annika)\n- [simd-json](https://crates.io/crates/simd-json)\n- [tinyjson](https://crates.io/crates/tinyjson)\n\nFor each library, each of the following tasks was benchmarked both on a large and a small JSON object (which can be found in the `json/` folder):\n- Retrieving the value of a single top-level property\n- Retrieving the value of a single fourth-level property\n- Parsing the entire JSON object\n## Benchmarking process\nThe benchmarks were taken under macOS 11.6 and rustc 1.57.0-nightly (8f8092cc3 2021-09-28) on a system with 16 GB of 2133 MHz RAM and a 2.4 GHz Intel i5-8279U CPU (with 4 physical and 8 logical cores).\nThe benchmarks were run sequentially with output redirected to a text file (`cargo bench \u003e bench.txt`, with minimal background processes.\n\nIf you run these benchmarks in a different environment and get significantly different results, feel free to open an issue and, if the results are reproducible, I will make note of them here.\n## Results\nThere are two main types of JSON parsing library:\n- _property-parsing libraries_ (Serde JSON, json-rust, simd-json, and tinyjson), which focus on retrieving the value of a particular JSON property, and have little to no ability to parse an entire JSON file at once\n- _object-parsing libraries_ (GJSON, A-JSON, and Pikkr), which parse an entire JSON object/file at once, and subsequently allow access to any value within the JSON file with minimal overhead\nEach of these library types has different applications; you need to figure out which one is best for your use case.\n\nAlthough I did my best to implement each benchmark for every library, the most relevant benchmarks for the property-parsing libraries are the `top_level` and `fourth_level` benchmarks (which retrieve a single value).\nConversely, the most relevant benchmark for the object-parsing libraries is the `parse_all` benchmark; the other benchmarks will take about the same time, since these libraries must parse the entire object before retrieving any values.\n### Object-parsing libraries\nThe fastest object-parsing JSON library benchmarked here was **json-rust**, which was about 2.7x faster than the second-fastest, Serde JSON, at parsing large objects and about 1.3x faster than Serde JSON at parsing small objects.\nIf you want the features of Serde, **Serde JSON** is 1.6x faster than simd-json for small objects; while parsing large objects, they are about equally matched, except that simd-json is 1.5x faster when parsing a single top-level property. (I'm not really sure why this is, since simd-json ostensibly parses the entire object at once. Maybe it's cleverly optimized at compile-time for top-level property accesses?)\nAlthough its syntax is rather clean, **tinyjson** has the worst performance of all the object-parsing libraries benchmarked here.\n\n![Performance graph of object-parsing libraries with large JSON objects](https://docs.google.com/spreadsheets/d/e/2PACX-1vQmREyK7BH0uoEHBLYVAhAqSQnPLf5sjwp__aa1MwuB0aZsRwPTGjAJTlkZAs7MQ6tjlwlI1AsYwBYG/pubchart?oid=1082717416\u0026format=image)\n![Performance graph of object-parsing libraries with small JSON objects](https://docs.google.com/spreadsheets/d/e/2PACX-1vQmREyK7BH0uoEHBLYVAhAqSQnPLf5sjwp__aa1MwuB0aZsRwPTGjAJTlkZAs7MQ6tjlwlI1AsYwBYG/pubchart?oid=1166695421\u0026format=image)\n### Property-parsing libraries\nIn many JSON-parsing applications, one only needs to retrieve a few properties from a JSON object. In this case, property-parsing libraries are significantly faster than object-parsing ones.\n\nThe fastest property-parsing library in every benchmark I ran is **GJSON**, which was two to five times faster than the next fastest property-parsing library (A-JSON). **Pikkr**, in spite of its speculative-parsing algorithm, was the slowest property-parsing library benchmarked (aside from in fourth-level property accesses on small JSON objects, where it outperforms A-JSON). In fact, the stateless Pikkr benchmarks (which introduce overhead from instantiating a new parser AND\ncan't take advantage of speculative parsing) were so slow on the small JSON object that I made a graph without them, to make it easier to compare A-JSON and GJSON.\n\n![Performance graph of property-parsing libraries with large JSON objects](https://docs.google.com/spreadsheets/d/e/2PACX-1vQmREyK7BH0uoEHBLYVAhAqSQnPLf5sjwp__aa1MwuB0aZsRwPTGjAJTlkZAs7MQ6tjlwlI1AsYwBYG/pubchart?oid=572340211\u0026format=image)\n![Performance graph of property-parsing libraries with small JSON objects](https://docs.google.com/spreadsheets/d/e/2PACX-1vQmREyK7BH0uoEHBLYVAhAqSQnPLf5sjwp__aa1MwuB0aZsRwPTGjAJTlkZAs7MQ6tjlwlI1AsYwBYG/pubchart?oid=44509521\u0026format=image)\n![Performance graph of property-parsing libraries with small JSON objects (no stateless Pikkr)](https://docs.google.com/spreadsheets/d/e/2PACX-1vQmREyK7BH0uoEHBLYVAhAqSQnPLf5sjwp__aa1MwuB0aZsRwPTGjAJTlkZAs7MQ6tjlwlI1AsYwBYG/pubchart?oid=325671513\u0026format=image)\n## Benchmarks\nAll benchmarks are available in the `bench.txt` file as well as in a [spreadsheet](https://docs.google.com/spreadsheets/d/1NqRzyH68OGFwUw4es-CqmcxVzl-ohact7f9jiacXW8g/edit?usp=sharing).\n### Serde JSON\nSerde JSON is the most popular JSON parser, with 46 million all-time downloads. It allows integration of JSON values with Rust's typing system; this behavior is not utilized in these benchmarks.\nSerde JSON is an object-parsing library, so the `serde_large_top_level` and `serde_small_top_level` benchmarks provide the most accurate measure of its performance.\n\nIts performance is okay, but not the best:\n```\ntest tests::serde_large_fourth_level           ... bench:     312,143 ns/iter (+/- 30,043)\ntest tests::serde_large_parse_all              ... bench:     311,408 ns/iter (+/- 13,977)\ntest tests::serde_large_top_level              ... bench:     309,296 ns/iter (+/- 7,600)\ntest tests::serde_small_fourth_level           ... bench:       1,283 ns/iter (+/- 41)\ntest tests::serde_small_parse_all              ... bench:       1,249 ns/iter (+/- 169)\ntest tests::serde_small_top_level              ... bench:       1,297 ns/iter (+/- 140)\n```\n### json-rust\njson-rust is another object-parsing library.\nThe `json_rust_large_top_level` and `json_rust_small_top_level` benchmarks provide the most accurate measure of its performance.\n\nIt has the best performance out of all the object-parsing libraries here!\n```\ntest tests::json_rust_large_fourth_level       ... bench:     112,779 ns/iter (+/- 5,560)\ntest tests::json_rust_large_parse_all          ... bench:     113,249 ns/iter (+/- 9,693)\ntest tests::json_rust_large_top_level          ... bench:     113,586 ns/iter (+/- 8,524)\ntest tests::json_rust_small_fourth_level       ... bench:       1,025 ns/iter (+/- 131)\ntest tests::json_rust_small_parse_all          ... bench:         982 ns/iter (+/- 139)\ntest tests::json_rust_small_top_level          ... bench:       1,009 ns/iter (+/- 185)\n```\n### simd-json\nsimd-json is an implementation of the Serde JSON API using x86_64 [SIMD instructions](https://en.wikipedia.org/wiki/SIMD); this means that it will only work on compatible Intel and AMD processors (ARM and other architectures will need to use a different library).\nIt is an object-parsing library, meaning that the `simd_large_top_level` and `simd_small_top_level` benchmarks provide the most accurate measure of its performance.\n\nIt performs slightly better than Serde JSON on large JSON files (and significantly better at top-level property accesses, although if that's all you care about, [GJSON](#GJSON) will perform better), and significantly worse on small ones:\n```\ntest tests::simd_large_fourth_level            ... bench:     306,219 ns/iter (+/- 13,723)\ntest tests::simd_large_parse_all               ... bench:     308,222 ns/iter (+/- 20,767)\ntest tests::simd_large_top_level               ... bench:     205,169 ns/iter (+/- 14,734)\ntest tests::simd_small_fourth_level            ... bench:       2,066 ns/iter (+/- 110)\ntest tests::simd_small_parse_all               ... bench:       2,011 ns/iter (+/- 624)\ntest tests::simd_small_top_level               ... bench:       2,423 ns/iter (+/- 1,013)\n```\n### tinyjson\ntinyjson is a JSON parsing that uses the `String::parse` API, so you can parse a string to JSON with a syntax as simple as `my_string.parse::\u003ctinyjson::JsonValue\u003e()?`.\nIt is an object-parsing library, so the `tinyjson_large_top_level` and `tinyjson_small_top_level` benchmarks provide the most accurate measure of its performance, which is quite poor:\n```\ntest tests::tinyjson_large_fourth_level        ... bench:     372,128 ns/iter (+/- 10,674)\ntest tests::tinyjson_large_parse_all           ... bench:     377,557 ns/iter (+/- 33,221)\ntest tests::tinyjson_large_top_level           ... bench:     372,601 ns/iter (+/- 56,079)\ntest tests::tinyjson_small_fourth_level        ... bench:       2,116 ns/iter (+/- 191)\ntest tests::tinyjson_small_parse_all           ... bench:       1,993 ns/iter (+/- 81)\ntest tests::tinyjson_small_top_level           ... bench:       2,056 ns/iter (+/- 147)\n```\n### GJSON\nGJSON is a port of the [Go JSON parser with the same name](https://github.com/tidwall/gjson) by the author of that package.\nIt is a property-parsing library, so the `gjson_large_fourth_level`, `gjson_large_top_level`, `gjson_small_fourth_level`, and `gjson_small_top_level` benchmarks are the ones to look at.\n\nIt is, by a significant margin, the fastest property-parsing library here!\n```\ntest tests::gjson_large_fourth_level           ... bench:      12,075 ns/iter (+/- 1,436)\ntest tests::gjson_large_parse_all              ... ignored\ntest tests::gjson_large_top_level              ... bench:       3,120 ns/iter (+/- 139)\ntest tests::gjson_small_fourth_level           ... bench:         239 ns/iter (+/- 30)\ntest tests::gjson_small_parse_all              ... ignored\ntest tests::gjson_small_top_level              ... bench:          92 ns/iter (+/- 7)\n```\n(The `parse_all` benchmarks are ignored because GJSON does not have a way to perform all the parsing for an object at once.)\n### A-JSON\nA-JSON is a port, by a different author, of Go's GJSON package.\nIt is a property-parsing library, so the `ajson_large_fourth_level`, `ajson_large_top_level`, `ajson_small_fourth_level`, and `ajson_small_top_level` benchmarks are the ones to look at.\n\nA-JSON performs worse than GJSON, but better than Pikkr at some tasks and worse at others:\n```\ntest tests::ajson_large_fourth_level           ... bench:      37,171 ns/iter (+/- 2,681)\ntest tests::ajson_large_parse_all              ... ignored\ntest tests::ajson_large_top_level              ... bench:      16,511 ns/iter (+/- 753)\ntest tests::ajson_small_fourth_level           ... bench:         782 ns/iter (+/- 463)\ntest tests::ajson_small_parse_all              ... ignored\ntest tests::ajson_small_top_level              ... bench:         183 ns/iter (+/- 16)\n```\n(Like GJSON, A-JSON's `parse_all` benchmarks are ignored because it can't frontload the parsing for an entire object.)\n### Pikkr\nPikkr is a property-parsing library with a unique 'speculative-parsing' approach. Its parser keeps track of state in an effort to make parsing more efficient.\nSince this approach does not work in all situations (for example, concurrent programs must create a new Pikkr instance for each thread), I've benchmarked both `pikkr_stateful` (which uses one Pikkr instance for all benchmark iterations) and `pikkr_stateless` (which creates a new Pikkr instance on each benchmark iteration).\n\nAlso, Pikkr's [original repository](https://github.com/melanieseltzer/pikkr/) has not been committed to in 2.5 years, and fails to build on my system. This benchmark uses [my fork](https://crates.io/crates/pikkr-annika), which fixes the build errors but is not maintained (except for reported security vulnerabilities).\n\nIt's possible that Pikkr would perform better in an environment ideal for its speculative parsing, but in this benchmark, it performs quite poorly:\n```\ntest tests::pikkr_stateful_large_fourth_level  ... bench:      20,237 ns/iter (+/- 627)\ntest tests::pikkr_stateful_large_parse_all     ... ignored\ntest tests::pikkr_stateful_large_top_level     ... bench:      19,985 ns/iter (+/- 2,192)\ntest tests::pikkr_stateful_small_fourth_level  ... bench:         693 ns/iter (+/- 48)\ntest tests::pikkr_stateful_small_parse_all     ... ignored\ntest tests::pikkr_stateful_small_top_level     ... bench:         508 ns/iter (+/- 18)\ntest tests::pikkr_stateless_large_fourth_level ... bench:      26,729 ns/iter (+/- 3,656)\ntest tests::pikkr_stateless_large_parse_all    ... ignored\ntest tests::pikkr_stateless_large_top_level    ... bench:      34,406 ns/iter (+/- 1,159)\ntest tests::pikkr_stateless_small_fourth_level ... bench:       4,327 ns/iter (+/- 290)\ntest tests::pikkr_stateless_small_parse_all    ... ignored\ntest tests::pikkr_stateless_small_top_level    ... bench:       2,419 ns/iter (+/- 287)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fannikacodes%2Frust-json-parsing-benchmarks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fannikacodes%2Frust-json-parsing-benchmarks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fannikacodes%2Frust-json-parsing-benchmarks/lists"}