Nifty / Tools / Code from JSON

JSON to Kotlin

Paste a JSON sample and get Kotlin data classes for it, including nested types and arrays.

json-to-kotlin
JSON sampleDrop a file here
Kotlin
Loading…

Runs in your browser. Nothing you paste is uploaded or stored.

How to use the JSON to Kotlin

  1. Paste a JSON sample on the left. Several examples in an array give better types.
  2. Name the top-level type.
  3. Copy the Kotlin code.

Questions

Is my data uploaded anywhere?

No. The tool runs entirely in your browser. Nothing you paste or drop is sent to a server, logged or stored, so it's safe for API responses, config files and other private data.

How are optional fields detected?

If you paste an array of objects and a field is missing from some of them, it's marked optional. More sample data gives more accurate types.

Can I do this in VS Code?

Yes. Nifty Paste JSON as Code pastes JSON straight into a Kotlin file as data classes.

Related tools