# nlohmann/json architecture

> Architecture diagram of the GitHub repository nlohmann/json, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nlohmann/json
- Repository: https://github.com/nlohmann/json
- Video tour (about a minute): https://gitdiagram.com/nlohmann/json/video

## Overview

nlohmann/json is a header-only C++ library for working with JSON values and converting between JSON and C++ types. The main workflow is to parse text or a supported binary format into a JSON value, inspect or edit it with container-style access, pointers, patches, or views, then serialize it or convert it to another type. The tree and README establish these capabilities; sampled implementation excerpts are limited, so internal call relationships are not asserted where they are not shown.

Main entry points: [`include/nlohmann/json.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/json.hpp) (JSON Value), [`include/nlohmann/json_view.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/json_view.hpp) (JSON View API), [`include/nlohmann/detail/input/parser.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/input/parser.hpp) (Text Parser), [`include/nlohmann/detail/input/binary_reader.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/input/binary_reader.hpp) (Binary Reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input Parsing"]
  node_text_parser["Text Parser<br/>[parser.hpp]"]
  node_lexer["Lexer<br/>[lexer.hpp]"]
  node_binary_reader["Binary Reader<br/>[binary_reader.hpp]"]
end

subgraph group_values["JSON Values"]
  node_api["JSON API<br/>[json.hpp]"]
  node_json_value["JSON Value<br/>[json.hpp]"]
  node_iterators["Container Iterators<br/>[iter_impl.hpp]"]
  node_pointer_patch["Pointer and Patch<br/>[json_pointer.hpp]"]
end

subgraph group_views["Views and Editing"]
  node_view_api["JSON View API<br/>[json_view.hpp]"]
  node_view_builder["View Builder<br/>[builder.hpp]"]
  node_view_editor["View Editor<br/>[edit.hpp]"]
  node_view_serializer["View Serializer<br/>[serializer.hpp]"]
  node_view_storage["Edit Storage<br/>[edit_storage.hpp]"]
end

subgraph group_output["Conversion and Output"]
  node_type_traits["Type Traits<br/>[type_traits.hpp]"]
  node_from_json["C++ Conversion<br/>[from_json.hpp]"]
  node_to_json["JSON Conversion<br/>[to_json.hpp]"]
  node_serializer["Text Serializer<br/>[serializer.hpp]"]
  node_binary_writer["Binary Writer<br/>[binary_writer.hpp]"]
end

node_developer(("C++ Application"))

node_developer -->|"uses"| node_api
node_api -.->|"parses text"| node_text_parser
node_text_parser -.->|"tokenizes input"| node_lexer
node_api -.->|"reads binary"| node_binary_reader
node_text_parser -.->|"produces values"| node_json_value
node_binary_reader -.->|"produces values"| node_json_value
node_developer -->|"accesses values"| node_json_value
node_json_value -.->|"iterates with"| node_iterators
node_json_value -->|"supports pointers"| node_pointer_patch
node_json_value -.->|"creates views"| node_view_api
node_view_api -.->|"builds views"| node_view_builder
node_view_api -.->|"edits document"| node_view_editor
node_view_editor -.->|"stores edits"| node_view_storage
node_view_api -.->|"serializes view"| node_view_serializer
node_developer -->|"converts from JSON"| node_from_json
node_developer -->|"converts to JSON"| node_to_json
node_json_value -->|"serializes text"| node_serializer
node_json_value -->|"writes binary"| node_binary_writer
node_type_traits -.->|"enables conversion"| node_from_json

click node_api "https://github.com/nlohmann/json/blob/develop/include/nlohmann/json.hpp"
click node_text_parser "https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/input/parser.hpp"
click node_lexer "https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/input/lexer.hpp"
click node_binary_reader "https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/input/binary_reader.hpp"
click node_json_value "https://github.com/nlohmann/json/blob/develop/include/nlohmann/json.hpp"
click node_iterators "https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/iterators/iter_impl.hpp"
click node_pointer_patch "https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/json_pointer.hpp"
click node_type_traits "https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/meta/type_traits.hpp"
click node_from_json "https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/conversions/from_json.hpp"
click node_to_json "https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/conversions/to_json.hpp"
click node_serializer "https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/output/serializer.hpp"
click node_binary_writer "https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/output/binary_writer.hpp"
click node_view_api "https://github.com/nlohmann/json/blob/develop/include/nlohmann/json_view.hpp"
click node_view_builder "https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/builder.hpp"
click node_view_editor "https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/edit.hpp"
click node_view_serializer "https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/serializer.hpp"
click node_view_storage "https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/edit_storage.hpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_text_parser,node_lexer,node_binary_reader toneBlue
class node_api,node_json_value,node_iterators,node_pointer_patch toneAmber
class node_view_api,node_view_builder,node_view_editor,node_view_serializer,node_view_storage toneMint
class node_type_traits,node_from_json,node_to_json,node_serializer,node_binary_writer toneRose
class node_developer toneIndigo
```

## Components

### Input Parsing

- [Text Parser](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/input/parser.hpp): `include/nlohmann/detail/input/parser.hpp`
- [Lexer](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/input/lexer.hpp): `include/nlohmann/detail/input/lexer.hpp`
- [Binary Reader](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/input/binary_reader.hpp): `include/nlohmann/detail/input/binary_reader.hpp`

### JSON Values

- [JSON API](https://github.com/nlohmann/json/blob/develop/include/nlohmann/json.hpp): `include/nlohmann/json.hpp`
- [JSON Value](https://github.com/nlohmann/json/blob/develop/include/nlohmann/json.hpp): `include/nlohmann/json.hpp`
- [Container Iterators](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/iterators/iter_impl.hpp): `include/nlohmann/detail/iterators/iter_impl.hpp`
- [Pointer and Patch](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/json_pointer.hpp): `include/nlohmann/detail/json_pointer.hpp`

### Views and Editing

- [JSON View API](https://github.com/nlohmann/json/blob/develop/include/nlohmann/json_view.hpp): `include/nlohmann/json_view.hpp`
- [View Builder](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/builder.hpp): `include/nlohmann/detail/view/builder.hpp`
- [View Editor](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/edit.hpp): `include/nlohmann/detail/view/edit.hpp`
- [View Serializer](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/serializer.hpp): `include/nlohmann/detail/view/serializer.hpp`
- [Edit Storage](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/edit_storage.hpp): `include/nlohmann/detail/view/edit_storage.hpp`

### Conversion and Output

- [Type Traits](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/meta/type_traits.hpp): `include/nlohmann/detail/meta/type_traits.hpp`
- [C++ Conversion](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/conversions/from_json.hpp): `include/nlohmann/detail/conversions/from_json.hpp`
- [JSON Conversion](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/conversions/to_json.hpp): `include/nlohmann/detail/conversions/to_json.hpp`
- [Text Serializer](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/output/serializer.hpp): `include/nlohmann/detail/output/serializer.hpp`
- [Binary Writer](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/output/binary_writer.hpp): `include/nlohmann/detail/output/binary_writer.hpp`

### Other components

- **C++ Application**

## Connections

- C++ Application → JSON API: uses (evidence: `README.md`)
- JSON API → Text Parser: parses text
- Text Parser → Lexer: tokenizes input
- JSON API → Binary Reader: reads binary
- Text Parser → JSON Value: produces values
- Binary Reader → JSON Value: produces values
- C++ Application → JSON Value: accesses values (evidence: `README.md`)
- JSON Value → Container Iterators: iterates with
- JSON Value → Pointer and Patch: supports pointers (evidence: `README.md`)
- JSON Value → JSON View API: creates views
- JSON View API → View Builder: builds views
- JSON View API → View Editor: edits document
- View Editor → Edit Storage: stores edits
- JSON View API → View Serializer: serializes view
- C++ Application → C++ Conversion: converts from JSON (evidence: `README.md`)
- C++ Application → JSON Conversion: converts to JSON (evidence: `README.md`)
- JSON Value → Text Serializer: serializes text (evidence: `README.md`)
- JSON Value → Binary Writer: writes binary (evidence: `README.md`)
- Type Traits → C++ Conversion: enables conversion
