Report

Help us improve this tool

JSON To MobX State Tree

Convert JSON sample data into MobX State Tree model definitions with real-time browser-side Babel transformation.

O M T

Convert JSON into MobX State Tree models

MobX State Tree (MST) models describe application state with runtime type checking, snapshots, and actions. When you already have sample JSON from an API response or local fixture, hand-writing the matching t.model definition is repetitive. This tool inspects your JSON object and generates a ready-to-edit MST model using types as t helpers.

What this tool does

Paste a JSON object in the input panel. The converter maps each value to the closest MST type: strings become t.string, numbers become t.number, booleans become t.boolean, nested objects become nested t.model blocks, and arrays become t.array with inferred element types. The output includes the standard mobx-state-tree import so you can paste it into a store file.

Type mapping rules

  • String values map to t.string.
  • Integer and floating-point numbers map to t.number.
  • Booleans map to t.boolean.
  • null values map to t.null.
  • Nested objects become nested t.model definitions.
  • Arrays infer element types from their contents; mixed arrays fall back to t.array.

Common use cases

  • Bootstrap MST stores from API response samples.
  • Prototype state models before wiring actions and views.
  • Document expected payload shapes for frontend state containers.
  • Speed up migration from plain JSON fixtures to typed MST models.

Related tools

Generate TypeScript interfaces from JSON with the JSON to TypeScript POJO Generator, build Flow types with the JSON to Flow Converter, or validate and format JSON using the JSON Formatter.

Frequently Asked Questions

Does the input need to be a JSON object?

Yes. The root value must be a JSON object because MST models describe named properties. Arrays and primitive values at the root are not supported.

Are actions and views generated?

No. This tool generates the model shape only. You still need to add .actions(), .views(), and any flow async logic yourself after pasting the output.

How are arrays handled?

Arrays with a single element type become t.array(elementType). When array elements are objects, nested models are created automatically. Mixed-type arrays default to a generic t.array.

Can I rename the generated model?

Yes. The output uses MyModel as a placeholder name. Rename it to match your store naming convention before exporting or registering the model.

Is my data sent to a server?

No. Conversion runs entirely in your browser. Your JSON never leaves your device.