JSON → Nim types
ClientPaste JSON to emit exported object types with seq for arrays and nested types for nested objects—refine with your JSON library and optional or ref fields as needed.
Review before using in a Nim project
The generator is a starting point, not a complete serialization contract. Check integer vs float choices, optional fields, reserved words, and the pragmas expected by your JSON library before committing the type file.
Learn more: JSON and Nim
Emit exported `object` types with `seq` for arrays—pair with std/json, jsony, or nim-json-serialization to decode real payloads.
Field names and JSON keys
Field identifiers use snake_case; when the JSON key differs, a `## JSON key: …` documentation line records the original string so you can add jsonKey-style pragmas if your library needs them.
JSON → Nim
?
Parses JSON in your browser and emits classes inferred from the sample shape. Nested objects become nested types; arrays use the first element only to guess item shape. Nothing is uploaded.
Fields use snake_case; ## JSON key lines document the original key when it differs. Prefer int over float when values are integers; add Option or ref for nulls per your JSON library.
Nearby workflows on Toolcore
- JSON formatter — when the sample still needs strict parse before you trust the inference.
- JSON → CUE — when configuration should be validated with CUE, not only Go structs.
- Compare JSON — after you change the sample and want to see structural drift.
Common use cases
- Sketch types before wiring std/json, jsony, or nim-json-serialization in a Nim service or CLI.
- Compare snake_case field names with camelCase keys from upstream JSON APIs.
- Turn a small API response into a starting model before you decide whether fields should be object, ref object, Option, or custom converters.
- Document an integration contract in Nim terms while keeping the original JSON sample beside the generated draft.
Common mistakes to avoid
Assuming JSON numbers are always float
This draft maps JSON numbers to float; switch to int when your contract is integer-only.
Treating missing fields as the same as null
JSON samples cannot prove whether a field is optional, nullable, or just absent in this response. Mark optional data deliberately in your Nim layer.
Forgetting library-specific pragmas
The output is plain scaffolding. Add jsony, std/json, or nim-json-serialization pragmas and custom key mapping in the style your project already uses.
FAQ
Is generation local?
Yes. Output is produced entirely in your browser.
Why does the generated code not include every Nim serialization pragma?
Nim projects commonly choose different JSON libraries and naming conventions. The page focuses on readable object scaffolding so you can add the exact pragmas your runtime expects.
How are arrays inferred?
Arrays become seq types. For arrays of objects, the generator uses the sample shape to draft a nested type; review heterogeneous arrays manually before relying on the output.
Common search terms
Phrases people search for that match this tool. See the full long-tail keyword index.
- json to nim types
- nim object from json sample
More tools
Related utilities you can open in another tab—mostly client-side.
JSON → Haskell records
ClientHaskell records with aeson Generic FromJSON/ToJSON from sample JSON—browser-side scaffolding.
JSON → CUE definitions
ClientCUE `#` definitions and list shapes from sample JSON—optional fields and disjunctions by hand, browser-only.
JSON → Rust structs (serde)
ClientSerde structs with JSON renames from sample data—local only.
YAML ↔ JSON
ClientYAML to JSON and JSON to YAML online—bidirectional converter, format either side in the browser.