Convert JSON to YAML in VS Code [Complete Guide]
Convert JSON to YAML in VS Code using extensions like "YAML" by Red Hat
or "JSON to YAML" converter extensions. Install the extension, open your JSON file,
press Ctrl+Shift+P, type "Convert JSON to YAML", and select the command.
This guide covers the best vscode json yaml extensions and conversion methods. Not sure which
format to use? See our YAML vs JSON comparison.
Best VS Code Extensions for JSON to YAML
Here are the top vscode json to yaml extension options:
1. YAML by Red Hat (Recommended)
- Downloads: 20M+ installs
- Features: YAML validation, auto-completion, formatting
- Schema support: Kubernetes, Docker Compose, GitHub Actions
- Install: Search "YAML" in Extensions (Ctrl+Shift+X)
2. JSON to YAML Converters
- "JSON to YAML" by ahebrank: Direct conversion command
- "Convert JSON to YAML": Simple one-click conversion
- "YAML ❤️ JSON": Bidirectional conversion
How to Convert JSON to YAML in VS Code
Method 1: Using Extension Command
- Install extension: Open Extensions (Ctrl+Shift+X), search for "JSON to YAML", install
- Open JSON file: Open the .json file you want to convert
- Open Command Palette: Press
Ctrl+Shift+P(orCmd+Shift+Pon Mac) - Run convert command: Type "Convert JSON to YAML" and press Enter
- Save: Save the result as .yaml or .yml file
Method 2: Using Built-in Terminal
Use VS Code's integrated terminal with CLI tools:
# Open terminal in VS Code: Ctrl+` (backtick)
# Using yq
yq -P config.json > config.yaml
# Using Python
python -c "import json,yaml,sys; print(yaml.dump(json.load(open('config.json'))))" > config.yaml
Method 3: Copy-Paste with Online Tool
- Select all JSON content (Ctrl+A)
- Copy (Ctrl+C)
- Open our online converter
- Paste and convert
- Copy YAML back to VS Code
Convert YAML to JSON in VS Code
The same extensions support yaml to json vscode conversion:
- Open your .yaml file in VS Code
- Press
Ctrl+Shift+Pto open Command Palette - Type "Convert YAML to JSON"
- Select the command to convert
- Save as .json file
Extension Comparison
| Extension | Convert | Validate | Format | Schema |
|---|---|---|---|---|
| YAML by Red Hat | ❌ | ✅ | ✅ | ✅ |
| JSON to YAML | ✅ | ❌ | ❌ | ❌ |
| YAML ❤️ JSON | ✅ | ❌ | ✅ | ❌ |
Recommendation: Install "YAML by Red Hat" for editing + a converter extension for the best experience.
Useful Keyboard Shortcuts
| Action | Windows/Linux | Mac |
|---|---|---|
| Command Palette | Ctrl+Shift+P |
Cmd+Shift+P |
| Extensions Panel | Ctrl+Shift+X |
Cmd+Shift+X |
| Toggle Terminal | Ctrl+` |
Cmd+` |
| Format Document | Shift+Alt+F |
Shift+Option+F |
Frequently Asked Questions
What is the best VS Code extension for JSON to YAML conversion?
YAML by Red Hat is the most popular extension with YAML language support and validation. For direct conversion, try "JSON to YAML" by ahebrank or "Convert JSON to YAML" extensions. They add command palette options for quick conversion.
How do I convert JSON to YAML in VS Code?
Install a JSON-YAML converter extension, open your JSON file, press
Ctrl+Shift+P to open Command Palette, type "Convert JSON to YAML",
and select the command. The converted YAML will appear in a new tab.
Can VS Code convert YAML to JSON?
Yes, the same extensions that convert JSON to YAML also support YAML to JSON
conversion. Use the Command Palette (Ctrl+Shift+P) and search for
"Convert YAML to JSON" to reverse the process.
Does VS Code have built-in JSON to YAML conversion?
No, VS Code doesn't have built-in JSON to YAML conversion. You need to install an extension or use an external tool. However, VS Code has excellent built-in support for both JSON and YAML syntax highlighting and validation.
Need to convert JSON to YAML quickly?
Use our free online converter—works in any browser, no extension needed.
Open Converter Tool →