Developer Tools

Clean API Data Before Importing

· QuickToolFlow
api json csv data cleanup

API data often looks usable at first glance. It is structured, machine-readable, and easy to copy. But importing raw API responses directly into a spreadsheet, database, dashboard, or internal tool can create quiet problems: missing fields, nested values, inconsistent types, duplicate records, and timestamps nobody can read.

A short cleanup workflow prevents those problems before they spread into reports or production systems.

Step 1: Validate the Response

Start by confirming that the response is valid JSON. A copied response can include extra logs, comments, partial output, or a truncated object.

Paste the response into the JSON Formatter & Validator. If it does not parse, fix the syntax issue before doing anything else. Formatting invalid JSON is like labeling boxes before checking whether the boxes have bottoms.

Once it parses, format it so nested objects and arrays are easier to inspect.

Step 2: Identify the Actual Records

API responses often wrap the useful records inside metadata:

{
  "page": 1,
  "total": 240,
  "data": [
    { "id": 1, "name": "Ada" },
    { "id": 2, "name": "Grace" }
  ]
}

The import target probably wants the records inside data, not the entire response object. Use the JSON Path Tester to locate the array you need, such as $.data[*].

This step is especially useful when responses include items, results, edges, nodes, or nested pagination structures.

Step 3: Check Field Names and Types

Before importing, review the keys and values:

  • Are required fields always present?
  • Are numeric values numbers or strings?
  • Are booleans true booleans or text values like "yes" and "no"?
  • Are timestamps in seconds, milliseconds, or ISO date strings?
  • Are nested objects expected by the destination?

If another system depends on a strict contract, validate the sample with the JSON Schema Validator. Schema validation helps catch type drift before the data reaches a database or analytics pipeline.

Step 4: Flatten Nested Data Carefully

Spreadsheets and CSV files prefer rows and columns. JSON often contains nested objects and arrays. That means flattening may be necessary:

{
  "id": 1,
  "profile": {
    "country": "US",
    "plan": "pro"
  }
}

This might become columns such as id, profile.country, and profile.plan.

Arrays need more thought. A list of tags can be joined into one cell, but a list of orders may need a separate table. Do not flatten nested data blindly if relationships matter.

Step 5: Convert Only After Cleanup

Once the JSON is valid, the record array is clear, and the fields look stable, convert it to the target format.

Use the JSON to CSV Converter when the destination is a spreadsheet, reporting tool, or simple table import. After conversion, check the CSV headers, row count, blank cells, and quoted values.

If you are moving in the other direction, use the CSV to JSON Converter after cleaning headers and delimiters.

Step 6: Normalize Dates and IDs

Timestamps and identifiers deserve a separate review. A 10-digit Unix timestamp usually represents seconds. A 13-digit timestamp usually represents milliseconds. Mixing them can shift dates by years.

Use the Timestamp Converter or Timestamp Batch Converter when logs or exports contain multiple date values.

For IDs, keep leading zeros if they are meaningful. Spreadsheet tools may turn 00123 into 123, which can break product codes, ZIP codes, and external IDs.

Import Checklist

Before importing API data, confirm:

  • The JSON parses successfully.
  • The record array has been identified.
  • Required fields are present.
  • Data types match the destination.
  • Nested objects and arrays have a clear flattening strategy.
  • Dates, IDs, and empty values have been reviewed.
  • The converted file opens correctly before final import.

Test With a Small Sample First

Before importing a full API export, convert and import a small representative sample. Include normal records, empty fields, long text, nested objects, arrays, unusual characters, and date values.

This smaller test helps you catch mapping problems before they affect hundreds or thousands of rows. It also gives you a chance to confirm how the destination handles missing values, duplicate IDs, type coercion, and leading zeros.

After the sample import succeeds, compare the record count and a few individual fields against the source response. Do not rely only on a successful import message.

Keep going

Related tools and guides

All tools