JSON Converter
Convert JSON to TypeScript, Python, Java, Go, C#, Rust and more, to Zod or Yup schemas, or to SQL and MongoDB inserts.
Runs in your browser. Nothing is uploaded.
How to use the JSON Converter
- Paste JSON into the left box, open a .json file, or press Load example for a sample that suits the current output.
- Pick the output under Convert to. Code covers TypeScript, Python, Java, Kotlin, Dart, Go, C#, Swift and Rust. Zod and Yup give validation schemas. SQL INSERT and MongoDB give database commands.
- Adjust the options that appear for that output, such as the root type name, the style, the database dialect or the collection name.
- The result updates as you type. Copy it or download it as a ready-named file.
One JSON sample, many destinations
Real JSON rarely stays JSON. An API response needs types before front-end code can use it safely, a form needs a validation schema, and a data export needs to land in a database table. Writing each of those by hand means reading the same structure again and again, and every pass is a chance to miss a field or get a type wrong.
This converter reads your JSON once and writes the version you need. Paste a sample on the left, choose an output on the right, and switch between outputs freely: the input stays where it is, so you can compare a Go struct with a Rust struct, or produce both the TypeScript types and the SQL seed for the same data, without pasting twice.
Code for nine languages
Every nested object becomes its own named type, arrays become typed lists, and the root type takes the
name you give it. Each language follows its usual conventions: interfaces or type aliases in TypeScript,
Pydantic models, dataclasses or TypedDicts in Python, records or classes in Java, Codable structs in
Swift, serde attributes in Rust and struct tags in Go. When a JSON key is not a valid identifier, or
uses a different naming style than the language expects, the generated code keeps the original key
through an alias or attribute so decoding still works.
Validation schemas
Types disappear at runtime, so data from outside your program still needs checking. Choose Zod or Yup to get a schema that mirrors the sample, ready to tighten with rules such as minimum lengths or allowed values. Zod output also exports an inferred type, so the schema and the type never drift apart.
Database inserts
Choose SQL INSERT for PostgreSQL, MySQL, SQLite or SQL Server. The converter collects the columns
from every object, picks a type that fits all the values seen, quotes names and values for the chosen
dialect and batches rows into multi-row INSERT statements. Choose MongoDB for insertMany or
insertOne commands you can paste into mongosh, with ISO date strings optionally stored as real dates.
Treat the output as a draft
Generated code is only as good as the sample behind it. A field that happens to be empty, or a number that happens to be whole, can lead to a narrower type than your real data needs. Paste a few varied records, read the result once, and adjust names and types before you commit it.
Frequently asked questions
Which JSON shapes work?
For code and schemas, paste an object or an array of objects. For SQL and MongoDB, paste one object or an array of objects; each object becomes a row or a document. A bare value such as 42 has no fields to describe, so it is rejected with a clear message.
How are optional and nullable fields detected?
When the JSON holds an array of objects, every item is compared. A key missing from some items becomes optional, and a key that is null in some items becomes nullable. More samples give a more accurate result, so paste several records if you have them.
Why do I see `unknown`, `Any` or `serde_json::Value` in the output?
That field was null in every sample, or held different types in different places, so there was nothing safe to infer. Replace it with the real type once you know it.
Are the SQL column types final?
They are a starting point. Whole numbers become integer or bigint, decimals become a floating-point type, ISO dates become timestamps and nested objects become JSON columns. Check them against your schema before running the script on a real database.
Do my settings carry over between outputs?
Yes. The JSON stays in the box when you switch outputs, and names, styles and database options are remembered in this browser for your next visit.
Is my JSON uploaded anywhere?
No. Every conversion runs in your browser, and nothing you paste is sent to a server.
Tutorials
How to add TypeScript types to an API response
Generate TypeScript interfaces from a user API response, then refine optional fields, unknown values and string unions before using them in fetch code.
How to import a JSON file into a PostgreSQL table
Turn a JSON export into a CREATE TABLE and INSERT script, review the column types, and load it into PostgreSQL with psql.
How to parse a weather API response with Pydantic
Generate Pydantic models from a weather API response, load the JSON with model_validate, and turn date strings into real datetime values.