JSON to YAML Without Python or PyYAML — Browser-Based
- Python + PyYAML is the canonical JSON-to-YAML script — but a browser converter skips the install entirely.
- Useful when Python isn't installed, the venv is broken, or you're on a machine where pip is blocked.
- For automation, keep Python. For one-offs, the browser wins on speed.
Table of Contents
The canonical Python snippet for JSON to YAML is three lines with json and yaml imports. It works great when Python is installed, PyYAML is already there, and you're in a shell ready to run it. When any of those isn't true, a browser converter is faster. This guide covers when each is right and the common pitfalls of the Python path.
The Python Script — Three Lines
import json, yaml
with open('input.json') as f:
print(yaml.dump(json.load(f), sort_keys=False))
Run with python3 script.py > output.yaml. Works when:
- Python 3 is installed.
- PyYAML is installed (
pip install pyyaml). - You're comfortable in a shell.
Fails when any of those is missing. A browser tab removes all three requirements.
When Python Is a Headache
- Python isn't installed. Modern macOS ships without system Python; Windows may have it, may not. Browser needs no runtime.
- PyYAML isn't installed.
pip install pyyamlrequires pip, which requires Python. A chicken-and-egg on fresh machines. - The venv is broken. venv activation issues, Python version mismatch with the project — common sources of delay.
- You're on a locked-down machine. Corporate policies often block pip installs. Browser works without admin rights.
In these cases, our browser converter gets you a YAML file in under a minute.
Sell Custom Apparel — We Handle Printing & Free ShippingWhen Python Is the Right Tool
- Batch conversion. 100 JSON files in a directory — a Python script with
pathlibhandles it cleanly. - Schema validation. PyYAML + jsonschema libraries let you validate output against an OpenAPI or JSON Schema spec.
- Automation. CI pipelines, cron jobs, or deploy scripts. Python runs anywhere the CI image does.
- Custom transformations. Convert + transform keys + filter arrays, all in one script.
For any of these, install Python + PyYAML. For one-off conversions, don't bother.
Ruamel.yaml — When PyYAML Isn't Enough
PyYAML doesn't preserve comments, custom formatting, or quoting styles on round-trip. ruamel.yaml does — the recommended pick when you need to read a YAML, modify it programmatically, and write it back without losing formatting.
For plain JSON-to-YAML (write-only), PyYAML is fine. For round-trip editing, use ruamel.yaml. For one-off conversions, use the browser.
One-Liner Options
# Python one-liner python3 -c "import json,yaml,sys; print(yaml.dump(json.load(sys.stdin)))" < input.json # With ruamel.yaml python3 -c "import json,sys; from ruamel.yaml import YAML; YAML().dump(json.load(sys.stdin),sys.stdout)" < input.json # yq (not Python) yq -o yaml < input.json
All three work. All three require an install. Browser tool requires a browser — which you already have open.
Skip the pip install
Browser-based conversion for one-off work. Keep Python for automation and batch jobs.
Open Free JSON to YAML ConverterFrequently Asked Questions
Does PyYAML produce different output than my browser tool?
Minor formatting differences — PyYAML defaults to 2-space indent and alphabetical keys. Our browser tool uses 2-space indent and preserves source order. Both produce valid YAML that any parser accepts.
Can I convert a huge JSON file faster with Python than the browser?
For 10MB+ files, yes — Python streams efficiently. Under 10MB, both are fast enough. Install yq for the best large-file performance, not Python.
What about json.dumps → yaml parsing round-trip?
Don't — round-tripping through JSON loses YAML-specific features (anchors, comments, custom tags). If you need round-trip editing, work directly in YAML with ruamel.yaml.
Is there a Python library that's better than PyYAML for JSON to YAML?
ruamel.yaml is more correct and preserves more information on round-trips. PyYAML is simpler. For one-way JSON to YAML, either works. For round-trip edits, use ruamel.yaml.

