Build your own JSON Parser
A JSON parser written by hand: a tokenizer, a recursive-descent parser, error messages with positions, and a round-trip test.
- Intro
- About 3–6 h
- 4 checkpoints
- 2 tutorials · Nim, Python
Pick a tutorial, then check yourself at each checkpoint. Work in any language you like.
Choose a tutorialWhy build it
Parsing turns text into structure, the first step of compilers, config loaders and APIs. JSON is the smallest real grammar to start with.
You will be able to
- Tokenise input into strings, numbers, literals and punctuation.
- Write a recursive-descent parser from a grammar.
- Report errors with line and column.
- Handle escapes and Unicode correctly.
Skills it exercises
Recommended on Data Structures & Algorithms.
How you know you are there
Work in any language. Each checkpoint ends with something you can run or observe, so you can check it yourself.
- Checkpoint 1Self-check
Tokenizer
Done when: Every JSON token type is recognised, including escaped strings and exponents.
- Checkpoint 2Self-check
Parser
Done when: Nested objects and arrays parse into native values that equal the standard library's result on 20 sample files.
- Checkpoint 3Self-check
Errors
Done when: Invalid input such as trailing commas or unclosed strings fails with a message giving line and column.
- Checkpoint 4Self-check
Conformance
Done when: The parser passes the JSONTestSuite cases it claims to support, and serialising then parsing round-trips.
Stretch goals
- A streaming parser for files larger than memory.
- Parse another small format, such as INI or TOML.
Step-by-step guides
Pick one in a language you know (tutorial languages: Nim, Python). They open on the author’s site.
- Python
JSON Decoding Algorithm(external site)
Python: a JSON decoder written as an explicit state machine.
- Nim
Writing a INI Parser(external site)
Nim: an INI parser, another small grammar to practise on.
Where to go next
- Build your own Programming Language
Intermediate · 20–40 h
Practice builds are self-paced: Tech Atlas does not track them or count them as evidence. To show a skill, take its knowledge check from the skill page.
Tutorials come from codecrafters-io/build-your-own-x (CC0, snapshot of 2026-07-14, commit aa17439; links checked on 2026-10-19). Each tutorial belongs to its author and keeps its own licence; Tech Atlas links to it and does not host it. Briefs, checkpoints and the mapping to skills are Tech Atlas editorial drafts.