Omnikit
DevFilesMoneyAll tools
Ctrl K
Dev toolsFile toolsMoney calculatorsAll tools
HomeDeveloper toolsJSON to Java Class Converter
EnglishالعربيةবাংলাDeutschEspañolFrançaisPolskiPortuguêsРусский

JSON to Java Class Converter

dev

Turn a JSON sample into Java POJOs, records or Lombok classes annotated for Jackson

Runs in your browser. Nothing you type is sent anywhere. Checked against sources on 16 Oct 2026.

Paste a JSON sample and get Java classes annotated for Jackson, as POJOs with getters and setters, records or Lombok @Data. Whole numbers become int, long past 2,147,483,647, any decimal makes a field double, and a value that is null or missing uses the boxed type, such as Integer.

Next:
  • JSON to Kotlin Data Class Converter Turn a JSON sample into Kotlin data classes for kotlinx.serialization, Gson or Moshi
  • JSON Formatter & Validator Format, validate, minify and sort JSON with exact error positions

How to convert JSON to a Java class

1

Paste a JSON sample, such as an API response, into the left box.

2

The Java appears as you type: one Root.java with a nested static class per object, camelCase fields and @JsonProperty where a key differs.

3

Choose POJO with getters and setters, a record (Java 16+), or Lombok @Data, and set the root class name.

4

Press Copy, or Download to save Root.java, and read the JSON with Jackson's ObjectMapper.

About JSON to Java Class Converter

Java reads JSON into classes, usually with Jackson, and every object in the JSON needs a class whose fields have the right types and names. This converter writes those classes from a sample, so a long API response becomes compiling Java in one paste.

How types are chosen.

JSON value Java type
"text" String
true / false boolean
42 (whole numbers only) int, or long beyond 32 bits
4.5 (any decimal seen) double
null, or missing in some items Integer, Boolean, Double
only null, or mixed kinds Object
[ ... ] List<...>
{ } empty Map<String, Object>
{ ... } a nested static class

One file. The output is a single Root.java: the root class holds every other class as a public static nested class, which Jackson can create and which needs no extra files. When the JSON is an array or a single value, a comment names the type to read it as, such as List<Root.RootItem>.

Names and keys. Fields are camelCase, so user_name becomes userName with @JsonProperty("user_name") keeping the key. Java keywords get an underscore, such as class_. A field like xCoord is written xcoord, because Jackson would otherwise pair it with the getter getXCoord under a different name. An empty key is ignored with @JsonIgnoreProperties, since Jackson cannot name it.

Three styles. A POJO has private fields, getters and setters and works everywhere. A record (Java 16+) is short and immutable. Lombok @Data keeps the fields and lets Lombok write the rest.

The POJO output for 9 samples was compiled with javac and read by Jackson 2.17 with unknown keys and nulls in primitives treated as errors. Nothing you paste leaves the browser.

Frequently asked questions

How do I convert JSON to a Java class?

Paste a JSON sample into the converter and the Java appears beside it: one Root.java with a nested static class for each object. Add Jackson to the project and read the JSON with new ObjectMapper().readValue(json, Root.class), which fills every field from its key.

Why are the classes nested and static?

Putting every class inside Root keeps the whole model in one file that compiles as it is. Jackson can only create a nested class when it is static, because an inner class needs an instance of its outer class first, so every nested class is declared public static.

When is a field Integer instead of int?

A field uses the boxed type, such as Integer, Long, Double or Boolean, when the sample shows it as null or some objects leave the key out. A primitive int cannot hold null, and a missing key would quietly become 0, so the boxed type keeps a missing value apart from zero.

Should I use a POJO, a record or Lombok?

Records, from Java 16, are the shortest and immutable, and Jackson 2.12 or later reads them directly. A POJO with getters and setters works on any Java version and with every library. Lombok's @Data writes the getters and setters for you at compile time, keeping the source short.

Why is a key like xCoord written as the field xcoord?

Jackson finds properties through getters, and it names getXCoord as xcoord by lowering the leading capitals. A field called xCoord would then not meet its own getter, and the property would split in two. The field is named xcoord, with @JsonProperty("xCoord") keeping the original key.

Is my JSON uploaded?

No. The conversion runs in your browser with no request to any server, and the JSON is not stored, so API responses holding tokens or personal data stay on your device. Close the tab and nothing remains.

Sources

  • The Java Language Specification, chapter 3 (identifiers and keywords)Which names are reserved; string literal escapes
  • The Java Language Specification, §8.10 Record classesRecord components, nested records being static
  • Jackson annotations wiki@JsonProperty and @JsonIgnoreProperties
  • Project Lombok, @DataGetters, setters, equals and toString generated from fields

Last verified 16 October 2026.

Rates and rules change; check the source before you rely on a figure.

Still stuck? Ask about JSON to Java Class Converter and anybody who knows can answer. No account needed.

Common uses

  • JSON to POJOPaste an API response and get a Java POJO with getters, setters and Jackson annotations

Same job, other tools: TSV to JSON – Convert tab-separated values, such as a paste from Excel, into JSON · JSON to YAML – Turn JSON into clean, readable YAML for configs · Query String Parser – Split a URL query string into a table of decoded parameters.

Related tools

All developer tools
Base64 Encode & DecodeText and files to Base64 and back, with URL-safe mode and image previewUnix Timestamp ConverterUnix timestamps to dates and dates to timestamps, in any time zoneJSON to TypeScriptGenerate TypeScript interfaces or types from a JSON sampleCSV to JSONConvert CSV to JSON and JSON to CSV, with a table previewYAML to JSONConvert YAML to JSON and JSON to YAML, with anchors resolvedURL Encoder / DecoderPercent-encode or decode text and URLs, and see every part of a linkColor ConverterHEX, RGB, HSL, HWB, OKLCH and CMYK in both directions, with a contrast checkNumber Base ConverterBinary, octal, decimal, hex and any base to 36, exact at any size, with two's complement
Was this tool helpful?
Omnikit

Small jobs, done in your browser. Free, fast and private. Files are never uploaded.

Files

  • Compress Image
  • Image to PDF
  • Merge PDF
  • Compress PDF
  • PDF to Word
  • Word to PDF

Dev

  • JSON Formatter & Validator
  • Base64 Encode & Decode
  • JWT Decoder, Verifier & Encoder
  • Password Generator
  • UUID Generator
  • Unix Timestamp Converter

Money

  • SIP Calculator
  • EMI Calculator
  • GST Calculator
  • FD Calculator
  • PPF Calculator
  • Lumpsum Calculator
EnglishالعربيةবাংলাDeutschEspañolFrançaisPolskiPortuguêsРусский
GuidesQuestionsAboutHow we checkLaw library (beta)PrivacyTermsDisclosureContactMore: Exam practice (UGC NET Paper 1)Runs in your browser. Nothing is uploaded. © 2026 Omnikit (theomnikit.com)