English

Developer tools · Syntax converters

Turning kubectl JSON output into a manifest you can actually read

· Why it matters

json yaml developer-workflow

A dense JSON resource opening into an indented YAML tree for inspection
Original ToolAcre vector illustration

Kubernetes tooling emits JSON that is precise but hard to scan, while manifests are written in YAML. This post shows why converting between them speeds up reading, comparing and reusing resource definitions.

Two hundred lines of braces at 2 a.m. — a Deployment fetched as JSON and the field you need buried in the status block

During an incident, a large resource object can bury the relevant selector or condition among metadata and status. Converting the captured JSON to indented YAML removes punctuation without changing the ordinary object, array, Boolean, number, string and null values. The gain is visual scanning, not a new source of truth.

Redact tokens, addresses and identifiers before using any browser page. ToolAcre parses JSON strictly and dumps YAML locally. It does not contact a cluster or know whether the object came from kubectl, another client or a saved fixture.

Why the API speaks JSON and humans write YAML — the API server's format, the manifest tradition, and why both describe the same object

The same JSON-shaped resource tree can be represented as YAML mappings and sequences. This repository does not establish why a particular Kubernetes component chooses one wire representation or how every API endpoint negotiates media types, so the article avoids turning common practice into an implementation claim about Kubernetes internals.

What can be proven is narrower: JSON input is parsed into a JavaScript value and js-yaml serializes that value in block style. Arrays remain ordered, object keys remain associated with the same values, and ambiguous strings receive protective quotes.

JSON and YAML can carry the same resource tree; API transport claims are outside this converter’s evidence

Indentation and dashes make nesting easier to scan, while block scalars can make multiline strings readable. Those are serializer choices. They do not remove status, validate an API version, or make a live object suitable for reapplication. A quoted date-like string remains text even when YAML looks less explicit than JSON.

Use conversion to locate fields, compare shapes and prepare a review copy. Keep the original JSON for exact evidence. If a sorted-key option is enabled, object presentation changes further while array order remains untouched.

YAML changes presentation, not the Kubernetes object or its validity

A live object often contains fields maintained by its server or controllers. Removing `status`, `managedFields`, `uid` or `resourceVersion` may be appropriate for a reusable manifest, but ToolAcre does not know that policy and never strips them. Every deletion must be a deliberate Kubernetes-aware edit after conversion.

Other fields may be generated yet still necessary to preserve intent. Compare with the version in git and consult the owning system’s current documentation rather than applying a memorized cleanup list. The converter is intentionally blind to domain semantics.

Worked example: a Service fetched as JSON — converting to YAML, removing server-populated fields and comparing with the version in git

Take a redacted Service-shaped object with metadata, spec ports and a status block. Convert it to YAML, identify the server-populated fields using your operational procedure, and remove only those approved for the reusable artifact. Compare labels, selectors, ports and types with version control before any apply step.

The YAML writer may quote strings such as `NO`, `yes`, `1.0` or date-looking text to protect their types. Those quotes are not clutter to delete casually. Reconvert the edited YAML to JSON and compare the data tree, while remembering that comments added during editing cannot survive that reverse pass.

The reverse direction — converting a YAML manifest to JSON to see exactly what the API will receive, including how quoted values are typed

The reverse direction is available. YAML is read under either the strict JSON schema or Core schema, then JSON is written with selected indentation. The strict mode keeps `~`, empty values and `0o755` as text; Core resolves them differently. Neither treats `NO` as false.

This gives a clear view of what ToolAcre’s parser would send as JSON-shaped data. It does not prove what a cluster’s YAML library or schema admission will do, particularly for custom tags or application-specific fields.

What this does not cover — validating the manifest against the Kubernetes schema, which needs kubectl's dry-run or a schema tool

No Kubernetes schema, CRD definition or admission rule is loaded. Unknown fields, deprecated versions and invalid combinations may convert perfectly. Use the target platform’s dry-run or schema-aware validator for those questions.

ToolAcre also cannot authenticate, fetch a live resource or compare desired and observed state. Its job ends at syntax mapping. Keeping that boundary explicit prevents a readable file from being mistaken for an accepted manifest.

Takeaway: read in YAML, verify in JSON — and how the Syntax converters panel switches between the two without leaving the tab

Read a resource in the notation that helps the task, but verify its data and domain rules separately. JSON provides explicit punctuation; YAML provides a compact block view. For ordinary JSON-shaped values, the two can preserve the tree even though comments and style cannot round-trip.

Syntax converters switches between those views in the browser and exposes schema options and warnings. Use it as an inspection stage, not as authority to remove fields or deploy a resource.

For incident notes, record the original command output, the converted inspection copy and every manual deletion as separate artifacts. That trail lets another engineer distinguish what the cluster returned from what was removed for readability or reuse. It also prevents a clean YAML excerpt from being mistaken for the complete live resource. The converter contributes only the notation change; provenance and change control remain part of the operational workflow.