TFT

Add IDs to JSON Array

Automatically add unique identifiers to each object in a JSON array. Choose from UUID, sequential numbers, random strings, or custom patterns.

Add Unique IDs to JSON Arrays Instantly

This tool adds unique identifiers to each object in a JSON array. Paste your data, pick an ID format (UUID, sequential numbers, random strings, or custom patterns), and get back valid JSON ready for databases, APIs, or testing. Everything runs in your browser—no data leaves your machine.

How the ID generation works

The tool parses your input as a JSON array, then iterates through each object and prepends a new key-value pair containing the generated ID. The ID format depends on your selection:

  • UUID (v4): Uses the browser's native crypto.randomUUID() API to generate RFC 4122 compliant identifiers like 550e8400-e29b-41d4-a716-446655440000
  • Sequential: Simple incrementing integers starting from your chosen number (1, 2, 3... or 100, 101, 102...)
  • Random string: Alphanumeric characters generated client-side using Math.random(), with configurable length from 1 to 64 characters
  • Custom pattern: Replace {index} with the array position—useful for generating IDs like user_001 or item-2024-1

The output preserves your original object structure and adds the ID as the first property, maintaining insertion order in modern JavaScript engines.

When you'd actually use this

Importing CSV data into a database

You exported users from a legacy system as JSON, but there's no primary key. Add sequential IDs before running your INSERT statements into PostgreSQL or MySQL.

Creating mock API responses for frontend development

Your backend team hasn't built the endpoint yet. Generate realistic test data with proper UUIDs so your React components can handle real-world response structures.

Preparing data for Firebase or Firestore

NoSQL databases often need unique document IDs. Add UUIDs to your JSON array before bulk-importing into Firebase Console or using the Firebase CLI.

Testing React key prop behavior

You're debugging a list component and need stable, unique keys. Generate sequential or random IDs to test how your component handles re-renders and list updates.

Converting spreadsheet data for a headless CMS

Marketing gave you a Google Sheet of products. After converting to JSON, add custom pattern IDs like prod-{index} before importing into Sanity, Contentful, or Strapi.

Limitations and gotchas

This tool only works with JSON arrays—objects with curly braces won't be processed. If your input is a single object or nested structure, wrap it in square brackets first.

Random strings use Math.random(), which isn't cryptographically secure. For security-sensitive applications (like session tokens or API keys), use the UUID option instead, which leverages the browser's crypto API.

Very large arrays (thousands of objects) may cause brief browser lag since all processing happens client-side. For massive datasets, consider splitting into smaller chunks or using a Node.js script.

Frequently asked questions

Can I add IDs to nested JSON objects?

No—this tool only adds IDs to the top-level array items. If you need IDs on nested objects, you'd need to flatten your structure first or use a script with recursive traversal.

What happens if my JSON has syntax errors?

The tool will show an error message with details about what went wrong (missing comma, unmatched bracket, etc.). Fix the syntax issue before clicking "Add IDs".

Are the UUIDs guaranteed to be unique?

UUID v4 has 122 random bits, giving you about 5.3 × 10³⁶ possible combinations. The odds of collision are astronomically low—practically zero for any real-world use case.

Can I change the ID key name from "id" to something else?

Yes. Use the "ID Key Name" field to specify any property name like userId, _id (for MongoDB), or productCode.

Does this work with JSONL (JSON Lines) format?

Not directly. JSONL has one JSON object per line without array brackets. You'd need to wrap the lines in square brackets and add commas between objects first.

Is my data sent to a server?

No. All processing happens in your browser using client-side JavaScript. Your JSON never leaves your machine, making this safe for sensitive or proprietary data.