Generate Python TypedDicts from Complete JSON Examples
Infer Python TypedDict declarations locally, preserve exact dictionary keys and separate absent fields from None.
Tool workspace
JSON to Python
Python 3.11+ TypedDict declarations; standard library only.
NotRequired means an absent key; None means null. TypedDict does not validate runtime data. Integer lexemes use int; decimal or exponent lexemes use float, which can approximate numbers.
Enable JavaScript to generate code. You can still read and edit JSON.
This browser cannot start the local Worker. Generation is unavailable.
All elements and documents contribute to one contract. An array root stays an array. An absent field differs from null.
Up to 20 documents, 1,000,000 UTF-16 input units and 2,000,000 output units; other resource budgets also apply.
Your JSON is processed locally in a browser Worker. It is not uploaded or stored.
Changing to one document keeps only the active example. Confirm or cancel.
Use 1–64 ASCII letters and digits, beginning with a letter. Reserved names are rejected.
Ready for JSON input.
Some diagnostic details are omitted. Notice totals remain visible.
Name details
Clipboard is unavailable or denied. Download the file or explicitly open the complete code for manual copying. A large file may take longer to display.
Complete documents and all array elements
Paste strict JSON or choose a local UTF-8 file. Generate explicitly from one document or up to twenty complete examples of the same contract. Every array element and document contributes, including fields introduced at the end. A root array remains an array. Empty examples, decoded duplicate keys, comments, trailing commas and concatenated documents stop generation and preserve the input.
The editor shows the active example and total count. After generating, review the filename, root type expression, JSON node count and size of the complete code. These details describe the current result; copying and downloading include the full file even when the preview is shortened.
[{"id":1},{"id":2,"nombre":"Ana"}]
from typing import NotRequired, TypeAlias, TypedDict
RootItem = TypedDict("RootItem", {
"id": int,
"nombre": NotRequired[str],
})
Root: TypeAlias = list[RootItem]
Presence, None and exact keys
NotRequired[T] means a key was absent from some objects in its context; T | None means an observed null. For [{"x":null},{"x":"a"},{}], the field is NotRequired[str | None]. A required null-only field uses None, an optional null-only field uses NotRequired[None]. Absence does not add None or defaults. Objects in different fields have separate contracts.
Functional TypedDict syntax preserves dictionary keys such as class, a-b, the empty string, quotes, emoji and isolated surrogate escapes; only code identifiers are adjusted for collisions. Dependencies are declared before use. Python 3.11+ and only its standard library are required. TypedDict describes ordinary dictionaries and does not validate JSON or enforce required keys at runtime; no deserializer, dataclass, Pydantic model, dates or enums are generated.
Root [1,"x",null] becomes list[int | str | None]; [null] uses list[None], [] uses list[object] with a notice, and {} uses dict[str, object] because no fields were observed. A root null alias uses types.NoneType. Root primitive and union aliases use TypeAlias.
Numbers and complete local exports
Pure integer lexemes use int, including integers outside JavaScript’s safe range. A point or exponent selects float, also for mixed integer/decimal evidence. A parser precision notice remains visible even if int can preserve the original number; float emits an approximation notice when precision evidence is lost. Integer -0 produces a notice because int normalizes its sign. No sample values or coercions appear in the output.
Limits: 20 samples, 1,000,000 UTF-16 input units, 4,000,000 UTF-8 bytes in total and per file, depth 200, 100,000 nodes, 1,000,000 parse work units, 100,000 inference visits, 10,000 types, 20,000 fields, 2,000,000 merge work units, 2,000 declarations and 4,000,000 emission work units. Output allows 2,000,000 UTF-16 units and 8,000,000 bytes. Limits cannot necessarily be reached together; the operation times out after 15 seconds with no partial code.
The preview contains at most 20,000 UTF-16 units; copy and download include the entire current types.py, UTF-8 without BOM, LF and a final newline, as text/plain;charset=utf-8. At most 100 diagnostic details and 50 name rows totaling 10,000 units are shown, with omitted counts. Denied clipboard access offers explicit manual copying of the complete code. One initial BOM is removed for parsing; error positions refer to the visible original document. Cancel terminates the Worker and keeps all examples. Edits, options, sample order and mode changes invalidate output and exports.
Processing stays in a local browser Worker without uploads, storage or data in navigation links. JavaScript and Worker support are required. The page never imports, compiles or executes generated Python.