About the Sample JSON Generator
Use this sample JSON generator to describe the shape of your data once and get realistic JSON back: names, emails, prices, dates, UUIDs and more. Objects and arrays of objects can nest as deep as you need, and one click makes up to 1,000 records for an API mock, a test fixture or a UI prototype.
Hand-written mock data tends to be three tidy records called "Test 1" to "Test 3". Generated data looks closer to production, and it's better at finding problems: a list of 1,000 items that scrolls slowly, a null where your code expects an object, or a long paragraph that breaks a card layout.
The values come from faker, an open-source library that your browser downloads on your first click of Generate JSON. Your structure and the result stay in the browser. Names, phone numbers and addresses use faker's English (US) data, so expect US-style phone numbers and ZIP codes.
- Start from a template: click User, Product, Order or Blog post next to Templates. The fields appear under JSON Structure and a first result is generated right away. The page opens with the User fields already in place.
- Change any field: type its name and pick a type such as Full name, Email, Price, Date (ISO) or UUID. Add Field adds a new top-level field, and the trash icon removes one. A name turns red when it's empty or a sibling field already uses it.
- To nest data, set a field's type to Object and add fields inside it with the button under it, for example Add field to customer. For a list, choose Array, pick what it holds in the of menu and set Length (0 to 100). Choose Objects there, then Add field to each item, to get an array of objects.
- Set Number of records. 1 gives a single object; 2 to 1,000 gives an array of objects.
- Click Generate JSON. The result appears under Generated JSON with 2-space indentation. Click Copy, or Download to save
sample.json. Every click makes new values.
InputTemplate: Order
orderId UUID
customer Object (name, email)
items Array of Objects, Length 2
(product, quantity, price)
total Price
paid Boolean
createdAt Date (ISO)Output{
"orderId": "65ff24de-24e6-4e77-9ca2-6f4ecbe87bdc",
"customer": {
"name": "Janae Wolff",
"email": "kara28@hotmail.com"
},
"items": [
{
"product": "Fantastic Gold Towels",
"quantity": 1,
"price": 600.99
},
{
"product": "Licensed Steel Car",
"quantity": 6,
"price": 750.69
}
],
"total": 205.69,
"paid": true,
"createdAt": "2023-08-06T12:39:59.110Z"
}Each value is random on its own. total isn't the sum of the items, so calculate totals in your test code when an assertion depends on them.
Inputpage Index
total Number
data Array of Objects, Length 2
id Index, name Full name,
email Email, avatar URL
next NullOutput{
"page": 1,
"total": 551,
"data": [
{
"id": 1,
"name": "Jaydon Tremblay",
"email": "alessia_gottlieb59@gmail.com",
"avatar": "https://far-off-heartache.com"
},
{
"id": 2,
"name": "Chaz Sauer",
"email": "unique.stamm@gmail.com",
"avatar": "https://heartfelt-decongestant.info"
}
],
"next": null
}Index inside an array counts the items from 1. At the top level it counts the records. A Null field is handy for testing the last page of a list.
InputTemplate: Product
Number of records: 2Output[
{
"id": 1,
"name": "Bespoke Concrete Sausages",
"description": "Basium admitto cogito.",
"price": 664.25,
"inStock": true,
"tags": [
"usque",
"appello",
"atrocitas"
]
},
{
"id": 2,
"name": "Intelligent Silk Shirt",
"description": "Tempore credo cunabula summisse cerno ultra vereor temporibus ea aspicio.",
"price": 299.39,
"inStock": true,
"tags": [
"illum",
"blandior",
"thesaurus"
]
}
]With 2 or more records the top level is an array. Word, Sentence and Paragraph give Latin-style filler text, so it's obvious in a screenshot that the content isn't real.
What each field type produces
There are 19 value types plus Object and Array:
- Text: Word, Sentence and Paragraph give Latin-style placeholder text of growing length.
- Numbers: Number gives a whole number from 0 to 1000, Small number from 1 to 10, and Price a value from 1 to 1000 with up to two decimals, such as
664.25. Index is the position of the record or array item, starting at 1. - Boolean gives
trueorfalse. Null always givesnull. - UUID gives a version 4 UUID from the browser's
crypto.randomUUID(). Date (ISO) gives a UTC timestamp like2023-08-06T12:39:59.110Zfrom the last 5 years. - People and places: Full name, First name, Email (lowercase), Phone (US format, like
(213) 378-3310), Address (street, city, state and ZIP on one line, like427 Eryn Center, Port Juan, NM 14700), Company, URL and Product name.
Cover the edge cases, not only the happy path
Real API data is messier than a demo. A few settings make the mock closer to what your code will meet in production:
- Set an array's Length to 0 to check the empty state of a list, a table or a search page.
- Add a Null field where the real API sometimes leaves a value out, such as
deletedAtoravatar. - Use Paragraph in a field that's normally short, like a title, to see how your layout handles long text.
- Generate 1,000 records to test sorting, filtering and scrolling with a realistic amount of data.
- Keep IDs unique with Index or UUID. Number can repeat across records.
Serve the JSON as a mock REST API
JSON Server turns a JSON file into a REST API for local development. It needs an object at the top level, so generate an array of records here and put it under a key, such as users. Save the file as db.json and run the command below. You get GET /users, GET /users/:id, POST /users, PUT and PATCH /users/:id, and DELETE /users/:id at http://localhost:3000.
{
"users": [
{ "id": 1, "name": "Jaydon Tremblay", "email": "alessia_gottlieb59@gmail.com" },
{ "id": 2, "name": "Chaz Sauer", "email": "unique.stamm@gmail.com" }
]
}npx json-server db.jsonGenerate sample data in code
For test suites and seed scripts, create the data in code with a fixed seed. The same seed gives the same values on every run, so a failing test fails the same way twice.
import { faker } from "@faker-js/faker";
faker.seed(123);
const users = faker.helpers.multiple(
() => ({
id: faker.string.uuid(),
name: faker.person.fullName(),
email: faker.internet.email(),
}),
{ count: 5 }
);from faker import Faker
Faker.seed(123)
fake = Faker()
users = [
{"id": fake.uuid4(), "name": fake.name(), "email": fake.email()}
for _ in range(5)
]How do I generate an array of JSON objects?
Set Number of records to 2 or more, and the output becomes an array of objects. For an array inside each record, add an Array field and choose Objects in its of menu.
Can I generate sample JSON from a JSON Schema?
Not on this page. You build the structure with fields and types instead. If you already have a schema, a library such as json-schema-faker can generate matching data in code.
Is the generated data real?
No. Names, emails, addresses and phone numbers are random combinations from faker's word lists. Some emails use real domains like gmail.com, so never send mail to them from a test system.
Can I get the same JSON again?
Each click on Generate JSON makes new values. Download the file to keep a fixed set, or use faker with a seed in code, as shown above.
Why is a field name shown in red?
The name is empty, or another field at the same level has the same name. JSON object keys should be unique (RFC 8259), so only the last field with that name would appear in the output.
Can I get minified JSON or YAML?
The output is always indented with 2 spaces. Paste it into the JSON Formatter and click Minify, or convert it with JSON to YAML.
Can I export the data as CSV or SQL?
Not from here, because nested JSON doesn't fit into rows. For flat rows as CSV or SQL INSERT statements, use the Fake Data Generator.