Documentation article

What is Shape IR?

Shape IR is the shared semantic layer that keeps multi-format transformation work coherent.

Concepts10 min

Shape IR is the shared representation that lets the toolkit reason about schemas without binding every feature to one source format.

It is not just an implementation convenience. It is the product concept that keeps parser, generator, and future analysis work aligned.

Audience
Learners
Difficulty
Intermediate
Last updated
July 27, 2026
Traversal
See how visitors and walkers reuse the same structure.
First transformation
Apply the concept immediately in the interactive workflow.

Why it exists

Parsers translate source-specific schemas into Shape IR. Generators consume Shape IR and render a target format. That means every new format extension can plug into a shared core instead of multiplying one-off adapters.

The result is a clearer architecture and a much better foundation for diagnostics, comparisons, and future analysis layers.

What it optimizes for

A good intermediate representation should feel narrower than every source format while still being expressive enough for the workflows you care about.

  • It captures structural meaning instead of source syntax.
  • It keeps parser and generator responsibilities decoupled.
  • It makes reuse possible across traversal, diagnostics, and future tooling.

How to think about it

The real IR can grow beyond this sketch, but the core idea stays the same: preserve meaning in a reusable structure before targeting any specific output format.

A simplified Shape IR sketch

ts
type Shape =
  | {kind: "string"}
  | {kind: "number"}
  | {kind: "array"; element: Shape}
  | {kind: "object"; fields: Record<string, Shape>};