JSON to Flow Type
Turn a JSON sample into a Flow type in your browser. Absent and null fields stay distinct, and nothing is uploaded.
What the JSON to Flow generator does
Each object becomes an exact-ish Flow object type exported by name. A key that is absent from some elements is marked with a question mark on the key, which is Flow for may be undefined; a key whose value was null gets a leading question mark on the type, which is may be null. Keeping those two marks apart is the point: they are different checks, and a converter that collapses them produces types that hide a missing field.
How to use it
JSON to Flow Type: paste the JSON into the box above, set Root type name (default "Root"), and press Run to get the Flow type below.
Worked example
Input:
{
"orderId": "A-1001",
"total": 129.99,
"currency": "EUR",
"paid": false,
"customer": {
"email": "[email protected]"
},
"lines": [
{
"sku": "X1",
"qty": 2
},
{
"sku": "X2",
"qty": 1,
"discount": 0
}
]
}
Output:
// @flow
// Generated from a JSON sample in the browser by AllTools — nothing was uploaded.
// Rename and adjust to taste; the shape is inferred from one example, not a schema.
export type Root = {
orderId: string,
total: number,
currency: string,
paid: boolean,
customer: Customer,
lines: Array<Line>,
};
export type Customer = {
email: string,
};
export type Line = {
sku: string,
qty: number,
discount?: ?number,
};
Why it runs in your browser
The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads JSON and returns Flow type; reloading the page discards both.
Each object becomes an exact-ish Flow object type exported by name. A key that is absent from some elements is marked with a question mark on the key, which is Flow for may be undefined; a key whose value was null gets a leading question mark on the type, which is may be null. Keeping those two marks apart is the point: they are different checks, and a converter that collapses them produces types that hide a missing field.
Turn a JSON sample into a Flow type in your browser. Absent and null fields stay distinct, and nothing is uploaded.
How to use it
JSON to Flow Type: paste the JSON into the box above, set Root type name (default "Root"), and press Run to get the Flow type below.
Why it runs in your browser
The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads JSON and returns Flow type; reloading the page discards both.
What to Expect
Best for
- Converting JSON to Flow type when the data is already on screen.
What this tool keeps
- Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere.
Sample input
{ "orderId": "A-1001", "total": 129.99, "currency": "EUR", "paid": false, "customer": { "email": "[email protected]" }, "lines": [ { "sku": "X1", "qty": 2 }, { "sku": "X2", "qty": 1, "discount": 0 } ] }
Sample output
// @flow // Generated from a JSON sample in the browser by AllTools — nothing was uploaded. // Rename and adjust to taste; the shape is inferred from one example, not a schema. export type Root = { orderId: string, total: number, currency: string, paid: boolean, customer: Customer, lines: Array<Line>, }; export type Customer = { email: string, }; export type Line = { sku: string, qty: number, discount?: ?number, };
Frequently asked questions
How do I use the json to flow type?
JSON to Flow Type: paste the JSON into the box above, set Root type name (default "Root"), and press Run to get the Flow type below.
Is my input uploaded?
No. The text is parsed on this page with JavaScript and is never posted to a server.
Is there a size limit?
Yes: 5 MB per run. Larger input is refused with a message rather than freezing the tab.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.