DEV Community

chuanbuilds
chuanbuilds

Posted on

I finally stopped hand-indenting YAML. Here's the local converter I added to my toolkit

YAML is fine until it isn't. I keep a bunch of config files for side projects — CI pipelines, Docker compose, some Kubernetes manifests — and every time I need to move a JSON blob into one of them, I end up hand-converting it. That's how you get an hour of debugging a single missing space.

The annoying part is the tools. The converters you find by searching either upload your file somewhere or make you paste config into a third-party server. For a config file that contains API keys or internal URLs, that's a non-starter for me.

So I added a JSON ↔ YAML converter that runs entirely in the browser to my collection of client-side tools:

JSON to YAML converter

It does the two directions. Paste JSON, get YAML — or paste YAML, get JSON. Output is a one-click copy, nothing leaves the tab, no upload, no account. The conversion itself is standard library logic, not some ML thing, so what you get out is deterministic and lossless for valid input.

A quick example, because it's the kind of thing that looks trivial until you've been burned by it:

{
  "services": {
    "api": {
      "image": "registry.example.com/api:2.4",
      "ports": ["8080:80"],
      "environment": {
        "DB_HOST": "postgres",
        "DB_PORT": "5432"
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Hand-writing that as YAML means getting every level of indentation right:

services:
  api:
    image: registry.example.com/api:2.4
    ports:
      - 8080:80
    environment:
      DB_HOST: postgres
      DB_PORT: '5432'
Enter fullscreen mode Exit fullscreen mode

One wrong space and your container just... doesn't come up. The converter removes the whole class of mistake — you work in the format you're comfortable in, and paste the result into the config.

It joins 100-plus tools in the Untracked Tools collection, all client-side for the same privacy reason. If you deal with config files at all, bookmark the converter — it's one of those "saved me on a Friday afternoon" tools.

Top comments (0)