JSON to Django Model

Generates a draft Django models.Model from a JSON sample. Field lengths, nullability, indexes, and relations are placeholders and always need review before makemigrations.

Private by architecture: All processing is 100% client-side memory. Your data never leaves this browser tab.
JSON input
0 lines · 0 charsJSON
Django model output
Ctrl/Cmd+Shift+C
0 charsPython

About This Tool

Drafts a Django models.Model class from a JSON sample: strings become CharField, whole numbers IntegerField, decimals FloatField, booleans BooleanField, and nested objects/arrays JSONField: each with a TODO comment where a human decision (max length, choices, a real relation) is still needed. The swap button also runs backwards, turning an existing model class into realistic sample JSON by reading field names and types.

This is a starting draft, not a migration-ready schema, see the warning banner above. For a non-Django Python type instead, use JSON to Python.

Key Features

  • Type-to-field inference: maps JSON value types to the closest Django field class, each flagged with a review comment.
  • Reverse conversion: the ⇌ swap button turns a pasted Django model into sample JSON, picking realistic values (email, URL, UUID, FK id, M2M list) from the field name and type.
  • Null handling: a field observed as JSON null gets null=True, blank=True plus a comment to confirm the real type.
  • Configurable model name: the Model name field is PascalCased automatically into the class name.
  • Persistent draft warning: a banner above the editors stays visible as a reminder to review before makemigrations.

Example

{"title": "Post", "views": 12, "published": true}

produces:

class Model(models.Model):
    title = models.CharField(max_length=255)  # TODO: confirm max_length
    views = models.IntegerField()
    published = models.BooleanField(default=False)

FAQ

Can I convert Django models back to JSON?
Yes! Click the ⇌ swap button or toggle the Direction dropdown to generate mock JSON from any Django models.Model definition.
Is this migration-ready?
No. It is a starting draft. Every CharField length, nullability flag, and relation is a placeholder for a human to confirm.
How are nested objects and arrays handled?
As models.JSONField() with a comment suggesting you consider a related model instead, since JSON generation cannot infer your intended relational structure.
What happens to a field observed as null?
It is flagged with null=True, blank=True and a comment to review nullability and the actual field type.