What is JSON to Django Model Generator?
This tool converts JSON data into Django model definitions. It automatically infers Django field types from JSON values, generates proper Python naming conventions (snake_case), creates a Meta class with db_table, and includes a __str__ method for admin readability.
How to Use
- Set the app name prefix for ForeignKey references and db_table naming
- Paste your JSON data (object or array of objects) into the input area
- Click "Generate Django Models" and copy the output into your models.py file
Why Use This Tool?
Tips & Best Practices
- Provide an array of objects for better type inference across multiple records
- String values that look like decimal numbers (e.g., "29.99") are mapped to DecimalField
- Long text fields (over 100 characters) are automatically mapped to TextField
- The app name prefix is used for ForeignKey references and db_table naming
Frequently Asked Questions
How are JSON types mapped to Django fields?
JSON strings → CharField or TextField (based on length), integers → IntegerField, floats → DecimalField, booleans → BooleanField, ISO dates → DateField/DateTimeField, null → blank=True, null=True. Fields ending with _id are mapped to ForeignKey.
What is the app name prefix for?
The app name prefix is used in ForeignKey references (e.g., "myapp.Category") and in the db_table Meta option (e.g., "myapp_item"). This follows Django convention for avoiding table name collisions across apps.
How are field names converted?
JSON keys are converted to snake_case following Python naming conventions. For example, "userName" becomes "user_name", "isActive" becomes "is_active". The original JSON key is not preserved — use the snake_case version in your code.
Can I use this with an existing Django project?
Yes. Copy the generated model into your models.py file, adjust field options as needed (max_length, default values, etc.), then run python manage.py makemigrations and python manage.py migrate to create the database table.
Is my data sent to a server?
No, all processing happens entirely in your browser. Your JSON data never leaves your device.