Skip to content
← All workCase 05 / 06

POJO Generator

Developer tool

Year
2023 — 26
Built with
React 18, Monaco Editor, TypeScript, Vite 6 +3 more ↓
pojogenerator.vercel.app
POJO Generator — screenshot of the live site

(01) Overview

A developer tool that turns a JSON document into Java POJO classes — fields, getters and setters and a Guava toString — as you type. Nothing is uploaded; it all runs in the browser.

(02) Features

  1. 01Side by sideJSON on the left, the generated classes on the right, regenerated as you type.
  2. 02Real type inferenceEvery array element is read: object arrays merge their fields, [1, 2.5] becomes List<Double>, nested arrays become nested lists.
  3. 03Safe namesKeys that are not valid Java become valid — first-name to firstName, class to class_ — and clashing class names are numbered.
  4. 04SettingsRoot class name, package and a header comment, validated and remembered between visits.
  5. 05ExportCopy a class, download it, or download every class in a .zip.

(03) Screens

pojogenerator.vercel.app
POJO Generator — Each nested object becomes its own class
03.1Each nested object becomes its own class
pojogenerator.vercel.app
POJO Generator — Settings, validated and remembered
03.2Settings, validated and remembered

(04) On a phone

Same app, smaller screen.

Captured from the live site at 390 pixels wide — the width of most phones in a hand.

POJO Generator on a phone — Stacked panes on a phone
Stacked panes on a phone

(05) Stack

Seven tools, and the job each one does here.

  • UIReact18Editor panes, file list and settings
  • UIMonaco EditorThe editor behind VS Code, bundled with only JSON and Java
  • LanguageTypeScriptThe generator and the interface
  • BuildVite6Builds to a static site
  • StylingTailwind CSS4Through the Vite plugin
  • TestingVitestGenerator tests against a baseline of expected output
  • HostingVercelStatic hosting

(06) Under the hood

  1. 01

    The zip is written by hand: a store-only zip writer with its own CRC-32 table, about seventy lines, so there is no compression library in the bundle.

  2. 02

    Monaco is bundled locally with only the JSON and Java languages and their workers, instead of being loaded from a CDN.

  3. 03

    Generation is debounced and memoised on the JSON and the settings, so typing stays smooth on large documents.

  4. 04

    Vitest checks the generator against a baseline file of expected Java output.

Next case

Notes