Tools
CSV to InfluxDB Line Protocol Converter
Paste or drop a CSV of timestamped readings and get InfluxDB line protocol back, ready for the CLI or the write API. Choose the measurement, the tag columns and the timestamp precision — the conversion runs in this page, and your data never leaves the browser.
Rows worth a look
Line protocol
What this tool does
A CSV of sensor readings is easy to produce and awkward to import. InfluxDB wants line protocol: one line per point, tags and fields in a fixed order, names escaped, strings quoted, and a timestamp as an integer in a known unit. This page does that translation in the browser and shows you exactly what it wrote, so you can read the output before it goes anywhere near your database:
- Reads the CSV you already have. Paste it, drop a file, or pick one from disk. Comma, semicolon, tab and pipe delimiters are detected, and quoted fields with embedded commas or newlines survive the trip.
- Lets you say what is a tag. Tick the columns that identify the reading. Tags are what you will group and filter by in Grafana, so this is the decision that matters most.
- Escapes to the line protocol rules. Commas, equal signs and spaces in names, quotes inside string values, and the space handling you prefer.
- Reports instead of guessing. Rows with an unreadable timestamp, an empty tag or no fields at all are listed with their line numbers rather than quietly dropped.
- Copies or downloads the result. A
.lpfile you can hand to the InfluxDB CLI, with the precision flag spelled out.
How a CSV row becomes a line
Line protocol has four parts, in this order: measurement, tag set, field set, timestamp — separated by a comma, a space and a space. Every CSV column ends up in one of them:
| Line protocol part | Comes from | Escaping applied |
|---|---|---|
| Measurement | The name you type in the form | Commas and spaces are escaped with a backslash |
| Tag keys and values | The columns you tick as tags | Commas, equal signs and spaces are escaped; keys are sorted alphabetically |
| Field keys | Every column that is neither the timestamp nor a tag | Commas, equal signs and spaces are escaped |
| String field values | Cells that are not numbers or booleans | Wrapped in double quotes, with quotes and backslashes escaped |
| Numeric field values | Cells that parse as numbers | No quotes and no escaping; whole numbers can take an i suffix |
| Timestamp | The timestamp column | No escaping — a plain integer in the precision you choose |
Fields are written in the column order of your CSV, tags are sorted by key, and a point with no field at all is invalid — which is why such a row is skipped and reported rather than written.
Timestamp precision, in and out
Line protocol timestamps are integers. The number alone does not say whether it means seconds or nanoseconds, so the unit travels with the write call, and getting the two out of step is the classic way to land readings in 1970 or in the far future.
- CSV timestamp unit describes your input. Leave it on automatic and the page reads the magnitude of the values: ten digits is seconds, thirteen is milliseconds, sixteen microseconds, nineteen nanoseconds. ISO-8601 datetimes are recognised too and read as UTC when they carry no offset.
- Output timestamp unit is what gets written. The default is nanoseconds, which is what InfluxDB assumes when no precision is given. Choose seconds or milliseconds if that is how you write, so the integers stay short and readable.
Converting to a coarser unit truncates, and the report says how many timestamps lost sub-unit detail. A value in seconds always converts up to milliseconds or nanoseconds exactly; the loss only happens on the way down.
Worked example
With the measurement sensor_readings, the columnsroom and device ticked as tags, output precision in nanoseconds, and otherwise the default settings, the example CSV on this page converts to:
sensor_readings,device=ths-01,room=kitchen temperature=21.4,humidity=48.2,battery=98 1788249600000000000 sensor_readings,device=ths-01,room=kitchen temperature=21.9,humidity=47.5,battery=98 1788253200000000000 sensor_readings,device=ths-02,room=hallway temperature=19.2,humidity=52.0,battery=71 1788249600000000000
Note the tag order: device before room, because tag keys are sorted. The fourth row of that example has an empty humidity cell, so that point is written withtemperature and battery only — the field is omitted, not stored as zero. The battery column is a whole number and is written as a float unless you ask for the i suffix.
Limitations
- This page writes a file. It does not connect to InfluxDB, does not know your bucket, org or token, and never sends your data anywhere.
- Line protocol has no null value. An empty cell either drops the field or becomes an empty string, depending on the option you pick.
- Timestamps read from an ISO-8601 string are millisecond-precise. Digits beyond milliseconds are truncated, and the report tells you when that happened.
- Two points with the same measurement, tag set and timestamp overwrite each other on write. That is InfluxDB's behaviour, not a conversion result, so de-duplicate before importing if your export repeats a reading.
- A string field value containing a line break has the break replaced with a space, because line protocol has no way to escape one.
- Files and pasted text are held in memory for the page session only. Nothing is written to browser storage.
FAQ
Does my CSV get uploaded anywhere?
No. The file is read by JavaScript in this page and converted in memory. There is no upload, no bucket, no account and no analytics event carrying your data. You can load the page, convert a file, then disconnect from the internet and the result is identical.
Which timestamp precision should I choose?
Pick the unit your CSV actually holds, then convert to the precision you write with. A Home Assistant export is usually seconds or milliseconds; a Zigbee or MQTT export is often milliseconds. The output timestamps are written in the output precision you select, so pass the same value as precision in the write call.
How do I get the file into InfluxDB?
Write the downloaded .lp file with the InfluxDB CLI, for example influx write with a bucket, org and token, and the precision flag matching your chosen output precision. This page produces the file only; it never contacts a server.
Why was a row skipped?
Three things make a row impossible to write: a timestamp that cannot be read, an empty tag value (line protocol does not allow one), or a row where every field cell is empty. Each skipped row is listed with its line number and the reason, so nothing disappears silently.
What happens to empty cells?
By default an empty, null or NaN cell is left out of the point, so the field simply is not written for that row. You can switch to writing an empty string instead, which stores the field with no characters — useful when a blank reading is itself meaningful.
Next step
Once the file is imported, the same readings are what the Zigbee network map visualizer reads for radio diagnostics, and the Zigbee2MQTT setup guide covers the MQTT side that usually produces these CSVs. If the export is part of a wider stack move, the coordinator guide covers the hardware and migration decisions around it.