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
Tip: Install both "YAML by Red Hat" for editing support AND a converter extension for one-click JSON/YAML conversion. Prefer command-line tools? See our CLI and yq guide.

How to Convert JSON to YAML in VS Code

Method 1: Using Extension Command

  1. Install extension: Open Extensions (Ctrl+Shift+X), search for "JSON to YAML", install
  2. Open JSON file: Open the .json file you want to convert
  3. Open Command Palette: Press Ctrl+Shift+P (or Cmd+Shift+P on Mac)
  4. Run convert command: Type "Convert JSON to YAML" and press Enter
  5. 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

  1. Select all JSON content (Ctrl+A)
  2. Copy (Ctrl+C)
  3. Open our online converter
  4. Paste and convert
  5. Copy YAML back to VS Code

Convert YAML to JSON in VS Code

The same extensions support yaml to json vscode conversion:

  1. Open your .yaml file in VS Code
  2. Press Ctrl+Shift+P to open Command Palette
  3. Type "Convert YAML to JSON"
  4. Select the command to convert
  5. Save as .json file
Note: Comments in YAML will be lost when converting to JSON, as JSON doesn't support comments. Learn more about these differences in our YAML vs JSON comparison.

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 →