DevConvert
Free Online Tool

Python Dict to JSON Converter

Convert Python dictionaries and objects to JSON instantly. Handles True/False/None, single-quoted strings, and tuple syntax. Free online Python dict to JSON converter.

Try sample:
Input
Output

Output will appear here

Press ⌘ Enter to convert

How It Works

  1. 1Copy a Python dict from your debugger, logs, or print statement
  2. 2Paste it into the converter
  3. 3DevConvert normalises Python syntax differences and outputs valid JSON

Examples

Simple dict

Input

{'id': 1, 'name': 'Alice', 'active': True, 'score': None}

Output

{
  "id": 1,
  "name": "Alice",
  "active": true,
  "score": null
}
Nested dict

Input

{'user': {'id': 1, 'address': {'city': 'Bangalore', 'pin': '560001'}}, 'verified': True}

Output

{
  "user": {
    "id": 1,
    "address": { "city": "Bangalore", "pin": "560001" }
  },
  "verified": true
}
Django queryset repr

Input

{'pk': 5, 'fields': {'title': 'My Post', 'published': True, 'views': 1234}}

Output

{
  "pk": 5,
  "fields": {
    "title": "My Post",
    "published": true,
    "views": 1234
  }
}

Frequently Asked Questions

What Python-specific syntax does this handle?

DevConvert handles: single-quoted strings, Python booleans (True/False → true/false), None → null, tuples converted to arrays, and basic Python object __repr__ output.

Can I convert output from print(vars(obj))?

Yes. Python's vars() and __dict__ output valid Python dict syntax that DevConvert can parse.

What about datetime objects in the dict?

Datetime objects are represented as strings in Python repr output (e.g. datetime.datetime(2024, 1, 1, 0, 0)). DevConvert converts them to their string representation in JSON.

Does it handle sets?

Python sets use {value, value} syntax which overlaps with dict syntax and is not reliably parseable. Convert sets to lists in Python first.

Related Tools