DevTools Hub

Guides › CSV Format, XML to JSON Conversion, and Generating Sensor Test Data

CSV Format, XML to JSON Conversion, and Generating Sensor Test Data

Different jobs call for different data formats. This page covers converting between CSV, XML and JSON, and generating fake data for testing systems.

CSV (comma-separated values)

CSV stores tabular data as comma-separated text. It is the most common format for spreadsheets, analysis tools, data loggers and PLC log exports. The standard is RFC 4180.

timestamp,sensor_id,temperature,humidity
2026-11-29T09:00:00Z,S01,23.5,45.2
2026-11-29T09:01:00Z,S01,23.6,45.0
2026-11-29T09:00:00Z,S02,"21,8",50.1

Rules

Garbled characters in Excel

Excel misreads UTF-8 CSV files without a BOM (the three bytes EF BB BF at the start), which garbles non-English text. Save with a UTF-8 BOM, or use Data → From Text/CSV and pick 65001 (UTF-8). In some European locales Excel expects semicolons as separators and commas as decimal marks, so values end up in one column.

CSV and JSON conversion

Each CSV row becomes a JSON object, with header names as keys.

[
  {"timestamp":"2026-11-29T09:00:00Z","sensor_id":"S01","temperature":"23.5","humidity":"45.2"}
]

XML and JSON conversion

<sensor id="S01" unit="C">
  <temperature>23.5</temperature>
  <tag>line1</tag>
  <tag>zone-a</tag>
</sensor>

{"sensor": {"@id": "S01", "@unit": "C", "temperature": "23.5", "tag": ["line1", "zone-a"]}}

XML has concepts JSON lacks, so converters follow different conventions.

Why test data matters

When building dashboards, databases, alarm logic or charts, real sensors are often not ready yet, and abnormal conditions are hard to create on purpose. Fake data lets you develop and verify first.

Random walk

value[n] = value[n−1] + small random change

Each value drifts a little from the previous one, which mimics slowly changing signals such as temperature, pressure or stock prices. Clamp it to a range, or it can wander off in one direction.

Sine wave

value(t) = center + amplitude × sin(2π × t / period) + noise

Good for periodic data such as daily temperature cycles, vibration or AC signals. A little noise makes it more realistic.

Values worth testing

This site's CSV generator creates up to 10,000 rows using random walk or sine patterns, and the Mock JSON generator creates up to 1,000 items for API testing, ready to download.

Code formatting tools: SQL, HTML, Markdown

Tools: CSV ↔ JSON · XML ↔ JSON · SQL formatter · HTML beautifier · Markdown viewer · JSON guide

Try it now: CSV Sensor Data Generator (runs in your browser, no data is sent anywhere)