YAML to Pike
Turn a YAML document into Pike typedefs and typed mapping declarations in your browser, no upload required.
Example
Input YAML:
name: Alice
age: 30
tags:
- admin
- user
Output Pike:
// mapping Root {
// string name;
// int age;
// array(string) tags;
// }
typedef mapping(string:mixed) Root;
typedef Root Root;How it works
Paste YAML and the tool parses it with js-yaml, walks the value to infer Pike types (int, float, string, arrays, mappings), and emits a typedef plus typed declarations. Nested objects become their own mapping typedefs.
Good to know
YAML to Pike takes a YAML document and generates matching Pike type definitions, so you can quickly scaffold the data structures your Pike program will read. It parses the YAML in your browser, walks the parsed value to infer types, and emits a commented field layout for each mapping plus typedef aliases. It is aimed at Pike developers who store config, fixtures, or API payloads in YAML and want a typed starting point instead of writing every declaration by hand.
Reach for it when you are wiring up a new config file, modeling a third-party response, or onboarding a YAML file whose shape you do not fully know yet. Paste the document, click Convert (or just edit the input, since it converts as you type), and the output pane shows each detected mapping as a commented block followed by a typedef mapping(string:mixed) alias. The Load sample button fills in a small nested example so you can see the format before using your own data.
Read the output top-down: the commented // mapping Name { ... } blocks document the inferred field names and their Pike types, while the real, compilable lines are the typedef statements. Because Pike has no native boolean, true/false values are reported as int(0..1); whole numbers become int, decimals float, text string, and anything null or unrecognized becomes mixed. Arrays show their element type when every item matches, for example array(string), and fall back to array(mixed) when the items differ.
A few practical notes. Type inference reflects only the sample you paste, so an optional field that is absent or a number that happens to be whole in your example may be inferred too narrowly; treat the result as a draft and widen types where your real data varies. Keys that are not valid Pike identifiers are emitted as comments rather than fields, and the emitted aliases use the generic mapping(string:mixed) form, so you will typically tighten the commented field types by hand before relying on them.
Frequently asked questions
How are YAML scalar types mapped to Pike?
Integers become int, decimals become float, booleans become int(0..1) (Pike has no native bool), strings become string, and nulls or empty values become mixed.
How are nested mappings and arrays represented?
Each nested mapping gets its own commented field layout plus a typedef mapping(string:mixed) alias, and homogeneous arrays become array(elementType) while mixed arrays become array(mixed).
Is my data uploaded anywhere?
No — this tool runs entirely in your browser. Your input never leaves your device and it works offline once loaded.
Is it free?
Yes, completely free with no sign-up and no limits.
People also ask
What is Pike used for?
Pike is a general-purpose, dynamically typed programming language with C-like syntax, often used for high-performance servers and network applications. Its type system includes types such as int, float, string, array, and mapping, which this tool targets when generating definitions.
What is a typedef in Pike?
A typedef in Pike creates a named alias for an existing type, letting you refer to a complex type by a single name. This tool emits typedefs such as typedef mapping(string:mixed) Root; so you can reference the generated structure by name.
Why does the tool output int(0..1) instead of a boolean?
Pike does not have a dedicated boolean type, so true/false values are represented as integers. The tool uses int(0..1), an integer restricted to the values 0 and 1, to capture the boolean nature of the value.
Does this tool validate my YAML?
It parses your YAML with the js-yaml library, and if parsing fails it shows an error message instead of output. It checks that the document is valid YAML, but it does not validate against any schema or check semantic correctness.
Can it handle nested objects and deeply structured YAML?
Yes. Each nested mapping is given its own generated name and rendered as a separate commented field block with a corresponding typedef. Nested arrays and objects are walked recursively so the full structure is reflected.
What happens to a YAML key that is not a valid Pike identifier?
Keys containing characters that are not allowed in Pike identifiers are not turned into fields. Instead, the tool emits a comment noting the original key and its inferred type so the information is not lost.
Is the generated Pike code ready to compile as-is?
The typedef lines are valid Pike, but the detailed field layouts are emitted as comments and the aliases use the generic mapping(string:mixed) form. You will usually refine the commented field types into concrete declarations before using them in production code.
Does YAML to Pike work offline?
Yes. The tool runs entirely in your browser and your input never leaves your device, so once the page and its YAML library have loaded it continues to work without a network connection.
Related tools