Privvert - private browser-based file toolsPrivvert

JSON → TypeScript

Interfaces generieren

Über dieses Tool

Paste any JSON sample and get strongly-typed TypeScript interfaces or types. Privvert detects optional fields by merging arrays of objects with different shapes, names nested types from their parent key, and quotes keys that aren't valid identifiers.

Useful for typing API responses, generating types from a config schema example, or kick-starting strongly-typed code from data you already have. Runs in your browser.

Funktionen

  • interface or type alias output
  • Merges array element shapes into one type with optionals
  • Names nested types from their parent key
  • Quoted keys for non-identifier names
  • Detects literal types where possible (booleans, common literals)
  • Browser-only - JSON never uploaded
  • Free and unlimited
  • Optional readonly modifier on every property

So funktioniert's

  1. Paste a JSON example.
  2. Set the root type name.
  3. Pick interface or type output.
  4. Copy the generated TypeScript.
🔒 100 % privat

Alles passiert direkt in deinem Browser mit JavaScript und WebAssembly. Deine Dateien werden nie hochgeladen, nie gespeichert und nie von uns gesehen.

Häufig gestellte Fragen

Can it infer string literal unions?

Currently it produces 'string'. Literal-union inference (e.g. 'red' | 'green' | 'blue' from samples) is on the roadmap.

How does it detect optional fields?

When you provide an array of objects, the tool merges all element shapes. Fields that are missing from any element become optional (?: T).

Will it generate enums?

TypeScript types only, not enums. Use a literal union (one type alias with | between values) - that's the modern TypeScript-recommended approach over enums.

What if my JSON has very deeply nested objects?

The tool generates a separate named type for each nested object. Names come from the parent key (e.g. user.address → Address).

Does it handle arrays of mixed types correctly?

Yes - it generates union types when the array contains different shapes. For arrays of objects with optional fields, the resulting interface marks the missing fields as optional automatically.

Can I customise the root type name?

Yes. Type the name you want at the top of the input - the output will use it as the root interface. Nested types get sensible names derived from the parent property name.