explaingit

json-iterator/go

13,905GoAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

jsoniter is a fast, drop-in replacement for Go's built-in JSON library, it encodes and decodes JSON data significantly faster and with less memory, requiring only a one-line import change in your existing Go code.

Mindmap

mindmap
  root((jsoniter))
    What it does
      Fast JSON decode
      Fast JSON encode
      Drop-in replacement
    Performance
      Less memory use
      Faster than stdlib
      Benchmark included
    Usage
      One-line swap
      Same API as stdlib
      Go get install
    License
      MIT permissive
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Speed up JSON serialization and deserialization in an existing Go service by swapping in jsoniter with a single import change.

USE CASE 2

Reduce memory allocations in a high-throughput Go API that processes large JSON payloads.

USE CASE 3

Benchmark JSON encoding performance in your own Go project to verify the speed gains match your specific data shape.

Tech stack

Go

Getting it running

Difficulty · easy Time to first run · 5min
MIT license, use, copy, modify, and distribute freely for any purpose, with no conditions beyond keeping the copyright notice.

In plain English

This repository, often called jsoniter, is a code library for the Go programming language that handles JSON. JSON is a common text format used to pass structured information between programs, for example what a web server sends back to an app. Go already comes with a built-in tool for this job, a standard package named encoding/json. The README describes jsoniter as a high-performance, 100 percent compatible drop-in replacement for that built-in tool. In plain terms, it does exactly the same work but faster, and you can switch to it without changing how your code is written. Most of the README is given over to a benchmark, which is a speed test comparing libraries. A table measures how long each option takes to decode and encode the same data, along with how much memory it uses. The figures show jsoniter decoding noticeably faster than Go's standard library while using far less memory, and edging out another library called easyjson. The author adds a sensible caveat: you should always run the test with your own data, because results depend heavily on what the data looks like. The usage section shows how little effort switching takes. Where you would normally import the standard encoding/json package and call its Marshal function (which turns Go data into JSON text) or Unmarshal function (which reads JSON text back into Go data), you instead import jsoniter and point a variable at its compatible configuration. After that one-line change, the same Marshal and Unmarshal calls work as before. A link points to fuller documentation for migrating from the standard library. Installing it is a single command, go get followed by the package address, which is the normal way to add a Go library. The README closes by welcoming contributions, listing several named contributors, and giving ways to get involved or ask for help: opening an issue or pull request, emailing the maintainer, or joining a Gitter chat room. The project is released under the MIT license. The README is short and focused purely on speed and compatibility.

Copy-paste prompts

Prompt 1
I have a Go HTTP handler that marshals structs to JSON using encoding/json. Show me exactly how to switch it to jsoniter with the compatible API and verify the output is identical.
Prompt 2
Write a Go benchmark test using testing.B that compares encoding/json and jsoniter for marshaling a slice of 1000 structs with mixed field types.
Prompt 3
My Go service is spending too much time on JSON decoding under load. Walk me through profiling it with pprof and switching the hot path to jsoniter.
Open on GitHub → Explain another repo

← json-iterator on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.