JSON to Pike
Paste JSON and get ready-to-use Pike class definitions with inferred types for every field.
Example
Given this JSON input:
{
"name": "Ada",
"age": 36,
"active": true,
"tags": ["a", "b"],
"address": { "city": "London" }
}The tool produces these Pike classes:
class Root {
string name;
int age;
int(0..1) active;
array(string) tags;
Address address;
}
class Address {
string city;
}How it works
The tool parses your JSON, infers a Pike type for each value (string, int, float, int(0..1) for booleans, array(...) for lists), and emits a class for the root object plus one class per distinct nested object shape. The root class is always named Root.
Good to know
JSON to Pike turns a sample JSON document into a set of Pike class definitions, mapping each field to an inferred Pike type so you don't have to hand-write the boilerplate. It's aimed at Pike developers who consume JSON from an API, config file, or database export and want a typed structure to model that data inside a Pike program. Because everything runs in your browser, you can safely paste production payloads without sending them to a server.
Reach for it whenever you have a concrete JSON example and need a starting skeleton for parsing or representing it in Pike, rather than passing around untyped mappings. It's especially handy for nested payloads: each distinct nested object becomes its own named class, and an array of objects is typed as array(ClassName), so you get a small class hierarchy instead of one flat blob. The entry point is always the Root class, which is what you map your decoded JSON onto.
Read the output top to bottom: scalar fields show their inferred type (string, int, float, or int(0..1) for booleans), and any field whose value is an object points to a separate class defined further down. The types are inferred only from the sample you paste, so they describe that example, not a guaranteed schema. A field that happened to be a whole number in your sample will be typed int even if the real source can return a decimal.
Practical tip: feed it the richest, most complete JSON you have. Empty arrays, null values, and arrays mixing different element types all collapse to mixed or array(mixed), which loses precision, and a value that is sometimes present and sometimes absent will only appear if it exists in the sample. Treat the generated classes as a fast first draft and tighten optional or polymorphic fields by hand.
Frequently asked questions
How are booleans and numbers typed in Pike?
JSON booleans become int(0..1) since Pike has no dedicated bool type, whole numbers become int, and numbers with a fractional part become float. Mixed or empty arrays fall back to array(mixed).
What happens with nested objects and arrays of objects?
Each nested object gets its own Pike class named after its field key, and an array of objects becomes array(ClassName). The root object is always emitted as the class Root.
Is my data uploaded anywhere?
No — it 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 programming language used for?
Pike is a dynamic, general-purpose programming language with a C-like syntax, historically used for high-performance network and web applications such as the Roxen web server. It supports object-oriented programming and has strong built-in support for data structures and JSON encoding/decoding.
How do you parse JSON in Pike?
Pike's standard library provides Standards.JSON.decode() to turn a JSON string into native Pike values (mappings, arrays, strings, ints, and floats) and Standards.JSON.encode() to serialize them back. The classes this tool generates give you typed structures to copy that decoded data into.
Does Pike have a boolean type?
Pike has no dedicated boolean type. By convention truth values are represented as integers, with 0 for false and any non-zero value for true, which is why this tool types JSON booleans as int(0..1).
What is the difference between int and float in Pike?
In Pike, int holds whole numbers (with automatic bignum support, so it does not overflow), while float holds floating-point decimal numbers. This tool infers int for JSON numbers without a fractional part and float for numbers that have one.
Can this tool generate Pike classes from a JSON array at the top level?
Yes. If the root JSON value is an array, the tool emits a typedef for the array's element type rather than a Root class, since an array is not an object with named fields. Wrapping your array inside an object will instead produce a proper class for the surrounding structure.
How does the tool name classes for nested JSON objects?
Each nested object is named after the JSON key that holds it, with the first letter capitalized and invalid characters replaced by underscores. If two different shapes would produce the same name, a numeric suffix is added to keep class names unique.
Are the inferred Pike types guaranteed to match my API's real schema?
No. The types are inferred only from the single JSON sample you paste, so they reflect that example and not the full range of values the source can return. Optional fields, nullable values, and varying number formats may need manual adjustment.
Related tools