·7 min read
Sample JSON Data for API Testing and Mocking
Testing REST APIs requires realistic sample data. This guide shows how to use free JSON files as mock API responses, test endpoints, and seed development databases — with code examples for JavaScript, Python, and curl.
Available JSON datasets
Download from our JSON files collection:
- Users (500 records) — name, email, age, city
- API response wrapper — status, data, pagination meta
- Large dataset (10K records) — performance testing
- GeoJSON — geographic coordinates for mapping
Using as a mock API endpoint
Fetch our JSON files directly as mock API responses during development:
// JavaScript — fetch as mock API
const response = await fetch(
'https://truefilesize.com/files/json/sample-users.json'
);
const users = await response.json();
console.log(users.length); // 500
# Python — requests
import requests
data = requests.get(
'https://truefilesize.com/files/json/sample-users.json'
).json()
print(f"Loaded {len(data)} users")
Mocking APIs in tests
// Jest + MSW (Mock Service Worker)
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import usersData from '../fixtures/sample-users.json';
const server = setupServer(
rest.get('/api/users', (req, res, ctx) => {
return res(ctx.json(usersData));
})
);
beforeAll(() => server.listen());
afterAll(() => server.close());
test('renders user list', async () => {
render(<UserList />);
expect(await screen.findByText('Alice')).toBeInTheDocument();
});
JSON structure types
Our collection includes multiple structures to test different parsing scenarios:
- Simple object — single key-value pairs
- Array of objects — most common API response format
- Nested objects — company → employees → addresses
- Null values — test null handling in your UI
- Unicode — Japanese, Chinese, Arabic, emoji
- Empty array — edge case for empty state rendering
Seeding a database
// Node.js — seed MongoDB
const users = require('./sample-users.json');
await db.collection('users').insertMany(users);
// Or seed with Prisma
for (const user of users) {
await prisma.user.create({ data: user });
}
Related data formats
Need data in other formats? Download CSV files for spreadsheets, XML files for SOAP APIs, or SQL dumps for direct database import.