snaptools
TS
JSON to TypeScript error
⌃⏎ run · clear · / focus input
// about this tool

JSON to TypeScript Online

Updated 2026-07-09

Convert JSON into TypeScript interfaces online for free. Paste any JSON object or array and SnapTools infers the field types — strings, numbers, booleans, arrays, and nested objects — then generates clean, ready-to-use interface definitions. Everything runs in your browser, so your JSON is never uploaded.

Writing interfaces by hand from an API response is tedious and error-prone: it is easy to mistype a field or miss a nested object. Paste a representative sample here instead and get a typed shape in one step, with nested objects broken out into their own named interfaces so the result is readable and reusable across your codebase.

// how to use

  1. 1 Paste a JSON object or array into the input panel on the left.
  2. 2 SnapTools infers the types and generates TypeScript interfaces as you type.
  3. 3 Read the generated interfaces on the right, then copy or download them into your project.

// examples

Object to interface
Input
{"id":1,"name":"Ada","active":true}
Output
interface Root {
  id: number;
  name: string;
  active: boolean;
}
Nested objects
Input
{"user":{"id":1,"roles":["admin"]}}
Output
interface User {
  id: number;
  roles: string[];
}

interface Root {
  user: User;
}

// common uses

Typing API responses without writing interfaces by hand Bootstrapping types from a sample payload or fixture Converting a JSON config file into a typed shape Learning how a JSON structure maps to TypeScript types

// faq

No. Type inference runs entirely in your browser, so your JSON never leaves your machine — safe for API responses and payloads that contain real data.
Each nested object becomes its own named interface, and the parent references it by name. This keeps the output readable and reusable instead of producing one deeply inlined type.
The generator inspects the array's elements and produces the narrowest type it can — a single type like string[] when the elements agree, or a union when they differ.
Types are inferred from the sample you paste, so a key that is present is treated as required. Paste a representative object, then mark fields optional with `?` if your real data can omit them.
Yes — that is the most common use. Paste a sample response from your endpoint and drop the generated interfaces straight into your client code.

Use this via API

Get a free API key →
curl -X POST https://snaptools.dev/api/v1/tools/json-to-typescript \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"json":"{\"id\":1,\"name\":\"Ada\",\"active\":true}"}'
Esc
↑↓ navigate open Esc close