---
title: "JSON to TypeScript Interfaces & Types | JSON Lark"
description: "Turn JSON samples into TypeScript interfaces or types, with optional keys inferred across items and samples, null handling and unions. In your browser."
url: https://jsonlark.me/
---

Sheet 01 Type generator

# JSON to TypeScript

Paste one JSON sample or several. JSON Lark draws up interfaces with optional keys, nullable fields and union types as you type, entirely in your browser.

## How it works

Every sample is read as a value of the root type. JSON Lark merges what it sees: a key missing from some objects becomes optional, a value that is sometimes `null` becomes nullable, arrays holding different kinds of values become unions, and objects with the same keys and types share one interface. Paste more samples in new tabs, or several documents in one tab as JSON Lines or separated by a `---` line.

### The general notes

- **Declare as, nested objects**: `interface` or `type` declarations, named for the key they came from (`repos` becomes `Repo`), or nested objects written inline.
- **Null values**: Keep `| null`, treat null as a missing key, or both.
- **String-literal unions**: Off by default. A string key with up to 8 distinct values, at least one of them repeated, becomes `"active" | "invited"`.
- **Note ISO dates**: Strings such as `2026-03-14T09:26:53Z` stay `string` (that is what JSON.parse gives you) with a comment saying they hold dates.

## More sheets in the set

The same inference for four more languages, plus tools for querying and changing JSON.

- [JSON to Go](https://jsonlark.me/json-to-go/): Structs with json tags, omitempty, pointers for nullable fields and optional time.Time.
- [JSON to Python](https://jsonlark.me/json-to-python/): Dataclasses, Pydantic v2 models or TypedDicts, with snake_case names mapped to your keys.
- [JSON to Rust](https://jsonlark.me/json-to-rust/): Serde structs with rename attributes, Option<T> and untagged enums for mixed values.
- [JSON to C#](https://jsonlark.me/json-to-csharp/): Classes or records with System.Text.Json or Newtonsoft attributes and nullable types.
- [JSONPath tester](https://jsonlark.me/jsonpath-tester/): Standard RFC 9535 queries with highlighted matches and normalized paths.
- [JSON Patch generator](https://jsonlark.me/json-patch-generator/): Diff two documents into an RFC 6902 patch, apply patches, or use Merge Patch.
- [Flatten JSON](https://jsonlark.me/json-flatten/): Nested JSON to dot or bracket path keys and back, round-trip safe, with CSV output.
- [Drawn in your browser](https://jsonlark.me/about/): Every tool here is JavaScript running in this tab. Nothing you paste is sent anywhere.

## Recommended

Two free tools from elsewhere for the testing that comes after the types.

Temp Mail API · disposable inboxes

### CleanTempMail

Testing sign-up, verification or password-reset flows end to end? The CleanTempMail Temp Mail API gives each test run its own disposable inbox and hands the messages back as JSON, ready for the types and JSONPath queries on this site.

It is paid once per request quota, with no subscription. For a quick manual check, the free inbox needs no sign-up and deletes mail after 3 days.

[Explore the Temp Mail API](https://cleantempmail.com/api)

Disposable cloud browser

### WebTraceCheck

Need to see how a page that consumes your API behaves in a clean Chrome, Firefox, Edge or Brave session, without your extensions or cookies? WebTraceCheck runs the browser on an isolated Linux desktop that is deleted after each session.

There is free daily time and nothing to install, plus free checks for DNS, redirects and security headers.

[Open a clean browser](https://webtracecheck.com/)

## Questions

**Is my JSON uploaded anywhere?**

No. The types are generated by JavaScript running in this tab, and the page makes no requests with your data. The site counts page views with Cloudflare Web Analytics, which sets no cookies and never receives what you paste.

**How does it decide which properties are optional?**

A key becomes optional when some objects of that type do not have it, counting every item of an array and every sample you paste. Untick "Optional keys from all samples" to make every key required.

**What happens with empty and mixed arrays?**

An empty array gives unknown[] until another sample shows what it holds. Mixed arrays become unions such as (number | string)[]. Objects keyed only by numbers or UUIDs become Record<string, T> instead of an interface with numeric keys.

**Why are numbers always number, never bigint?**

Because JSON.parse returns numbers, the type matches what your code receives. Integers beyond 2^53 lose precision in JavaScript; if your API sends such IDs, ask for them as strings. The Go, Rust and C# pages pick 64-bit integer types for them.

**My JSON has comments or trailing commas. Will it work?**

The generator reads strict JSON and shows the line and column of the first problem. To fix single quotes, comments, trailing commas or missing brackets first, use [JSONMender](https://jsonmender.me/), a sister site that repairs broken JSON.
