FREE DEVELOPER WORKSPACE

JSON to TypeScript.
Types you can inspect.

Turn JSON samples into readable interfaces and types. Understand missing fields, keep mixed values, and review the shape before it enters your codebase.

  • No account
  • Local generation
  • JSON + JSON Lines
TSAccount · interfaceEXAMPLE
export interface Account {
  id: number | string;
  name: string;
  email?: string | null;
}

email appears in 2 of 3 objects.
Optional and nullable are different evidence.

Fictional samples below. Inferred types, not runtime validation.

TYPE WORKSPACE

A clear shape for your data.

01 / SET THE SHAPE

Make the types yours.

Explicit choices. No guessed paths.

Used exactly as entered, including case. Up to 64 characters.

Object shapes use this style. Scalars, arrays and unions may need a type alias.

Keep the wrapper or array, or infer an item type from the selected array's items.

Missing fields and observed null values are different evidence.

Select a nested value

Blank keeps the whole value. Separate keys with /; escape a key's / as ~1 and ~ as ~0. A lone / selects an empty key, not the whole value. The path must resolve in every JSON Lines sample. Up to 4,096 characters; no automatic path selection.

More settings
02

One complete JSON value. No comments or trailing commas.

0 / 1,000,000 UTF-16 characters2 MiB UTF-8 limit · oversized edits are rejected, not cut

Ctrl + Enter or Cmd + Enter in this input.

03

Review your types

TYPE-ONLY

Inferred from samples. Not runtime validation.

A useful starting point.
Not a guessed contract.

Paste or import JSON, choose your settings, then generate. Your full type definitions will appear here.

  • Nested shapes, kept readableNamed declarations for structures in your samples.
  • Missing fields, made visibleReview optionality and real object-presence counts.
  • Complete code, your wayCopy all types or save a .ts or .d.ts file.
Generate and review before exporting

FROM RESPONSE TO REVIEW

Generate types in three deliberate steps.

  1. 01

    Bring representative JSON

    Paste a complete value or import UTF-8 JSON, JSONL, NDJSON or TXT. Include more than one example when fields or types vary. Generation starts only when you ask.

  2. 02

    Choose the boundary

    Set a root name and style. Keep the selected value or infer array items. For a wrapped response, use an explicit JSON Pointer such as /data/items.

  3. 03

    Check before you copy

    Review field presence and inference notes. Copy or download all declarations, then type-check them in your project. Changing input or settings invalidates the old result.

WHY EVERY SAMPLE MATTERS

A mixed ID. A missing email. Nothing hidden.

These three fictional records use root name Account, interface style and Infer array item. Other settings remain at their defaults.

JSON · three account samples

[
  {"id":101,"name":"Demo Finch","email":"finch@example.invalid"},
  {"id":"demo-102","name":"Demo Wren"},
  {"id":103,"name":"Demo Lark","email":null}
]

TypeScript · one item shape

export interface Account {
  id: number | string;
  name: string;
  email?: string | null;
}

id: number | string retains both observed types, not just the first value.

email? records its absence in one object; | null records an explicit null in another.

Keep selected value would instead preserve the root array with an item declaration. One sample cannot prove a field will always exist.

LESS GUESSWORK, BETTER STARTING TYPES

Built for real API-shape questions.

Look beyond the first record

Merge object observations at each structural location. Missing properties stay visible instead of becoming silently required.

Keep the shape you selected

Preserve a response wrapper or array, or explicitly infer its items. No guessed API path and no dropped mixed-value branches.

Review the evidence

See each property's type, optionality and presence count. Inspect individual declarations without accidentally exporting only a preview.

Fit your codebase

Choose interface or type, recursive readonly, indentation and property order. Copy full code or download a type-only .ts or .d.ts file.

NESTED JSON & MULTIPLE EXAMPLES

Select the data you actually need.

For {"data":{"items":[...]},"cursor":"..."}, the pointer /data/items selects the array. Then choose Infer array item for an item type. Wrapper metadata is deliberately outside that selection.

JSON Pointer uses ~1 for a slash in a key and ~0 for a tilde. Blank selects the whole value; / selects an empty key. Array indices must be canonical, such as /0, not /01.

In JSON Lines, each line is an example of the same root. The path must resolve in every sample; a missing later path fails rather than silently omitting data. Interior blank lines, comments, trailing commas, duplicate decoded keys and a JSONL BOM are rejected. One final newline is allowed.

New to response shapes? Start with the TypeScript beginner guide or practice with public developer APIs. Do not include credentials in your examples.

INTERFACE VS TYPE

Choose the style, preserve the shape.

An interface is a good fit for named object shapes and supports declaration merging. A type alias can also name scalar, array and union types. Neither choice makes the result a validated API contract.

Interface mode still uses a root type alias where necessary: for example type Root = number[];. Nested objects keep your chosen style. Different structural locations receive separate, collision-safe declaration names.

Readonly marks properties and arrays recursively at compile time; it does not freeze data. All properties optional is a deliberate override, not proof of missing data. Presence counts still show the actual observations.

With exports off, full output retains export {}; to stay module-scoped. A declaration-only download describes types; it does not create JavaScript values. Use the code in your project and review it with your compiler and tests.

CLEAR LIMITS, NO FALSE CERTAINTY

What the samples cannot tell you.

Inference is not validation

Objects at one structural location are merged; relationships between discriminator and payload fields are not preserved. There is no tagged-union, tuple, class, Date, bigint, JSON Schema or runtime-validator generation. Date-like strings remain strings, numeric JSON tokens become number, and there is no arbitrary URL import.

Only empty arrays produce unknown[]; null-only observations remain null. Only empty objects use { [key: string]: unknown } rather than the misleading broad {} type. Supply representative examples and review against the real API contract.

Privacy and literal values

Conversion runs in a local worker with no conversion uploads, AI calls or automatic workspace saving. Reloading clears the work; clipboard contents and downloads persist outside the workspace. Sitewide analytics and ads are separate, so this is not a claim that the entire page is isolated from third-party scripts.

String literal mode embeds source string values in exported code. It widens to string beyond 20 distinct values or 120 characters per value at a location. Observed literals are not a complete enum. Keys appear in output in every mode; use sanitized samples when the source is sensitive.

Bounded, not truncated

Input is limited to 1,000,000 UTF-16 characters and 2 MiB of UTF-8, with depth 40, 200,000 tokens/nodes and 10,000 JSONL samples or selected values. Inference supports up to 200 declarations and 2,000 generated properties, with 1,024-character keys and a 4,096-character pointer.

Full output is capped at 400,000 characters. The worker has a cancellable 15-second deadline. Limits reject an operation; they never offer a silently shortened file. The browser generates declarations but does not run a TypeScript compiler on your output.

A FEW USEFUL ANSWERS

JSON to TypeScript, explained.

How do I convert JSON to a TypeScript interface?

Paste JSON or import a UTF-8 file, choose a root name and interface style, then select Generate types. Nested objects get named declarations. Array, scalar and union roots use a type alias when needed. Review the result before using it.

How are missing fields, null and mixed arrays handled?

All selected samples are considered. A property missing from some objects at the same location becomes optional; an observed null adds a null branch. Mixed values form unions. Empty-only arrays use unknown[] because their element type is not known.

Can I use JSON Lines or a nested API response?

Yes. JSON Lines treats each line as another example of the same root, not an extra array. A JSON Pointer such as /data/items selects a nested value in every sample. Infer array item combines the selected arrays' direct items; a blank pointer preserves the whole value.

Should I choose interface or type, and does the result validate data?

Interfaces work for object shapes and support declaration merging. Type aliases also describe unions, arrays and scalars. Neither validates runtime JSON. This converter does not run a TypeScript compiler in your browser or generate runtime validators, classes or JSON Schema.

Is it free, and where is my JSON processed?

The converter is free with no account. Parsing and generation use a local browser worker, not an AI or upload API, and work is not saved automatically. Sitewide ads and analytics operate separately. String literal mode includes source string values in copied and downloaded code.

KEEP YOUR WORKFLOW MOVING

Inspect, type, then compare.

Use the JSON Formatter to inspect a response, JSON to CSV for a table export, or Diff Checker to review changed declarations.