json-tools .ru

YAML to Python dict

Parses YAML and outputs the same data as a Python literal — handy for hardcoding a config straight into a script for a quick test.

What happens to types

YAML true/false/null become Python True/False/None, and strings and numbers carry over as-is via repr(). The # comments common in YAML configs are not preserved in the Python literal.

Practical use

The result works well as a hardcoded fixture in tests, or as a default value in code before a YAML file is wired up to a config loader.

Format
YAML → Python
Source text Paste text or upload a file
Result Type is not detected yet
Statistics appear after formatting