LibreOffice Calc · Data management · Intermediate
Open JSON and Tabular XML Directly in LibreOffice Calc
Open small JSON and XML record files, verify fields and numeric types, and choose direct import rather than manual XML Source mapping.
Documentation-qualified; original fixture structure and arithmetic checked, native import and save/reopen pending · Editorial standards
Use File → Open when you want Calc to discover tabular records in a JSON or generic XML file automatically. Use mapped XML Source when you need to select XML elements and choose their destination in an existing sheet. These are different import workflows, not two names for the same dialog.
This guide covers the free desktop LibreOffice Calc application using English menus. Direct opening is documented in Calc Guide 26.2 and online Help labelled 26.8, checked on 23 October 2026. Those documentation versions are not a claim that the feature was introduced in 26.2, or that every earlier build supports it. The fixtures and expected arithmetic were checked independently; native import layout, cell types, dialogs and save/reopen behavior were not executed for this article.
Start with two representations of the same records
Download the original fictional JSON practice file and XML practice file. Keep them as separate local files. Neither needs an account, extension, macro or remote data connection.
The JSON contains a flat array with three objects:
[
{"sku": "KIT-01", "item": "Repair kit", "units": 8, "unit_cost": 12.5},
{"sku": "PAD-02", "item": "Note pad", "units": 15, "unit_cost": 2},
{"sku": "BOX-03", "item": "Storage box", "units": 6, "unit_cost": 4.75}
]
The XML expresses the same records using repeated stock elements:
<?xml version="1.0" encoding="UTF-8"?>
<inventory>
<stock><sku>KIT-01</sku><item>Repair kit</item><units>8</units><unit_cost>12.5</unit_cost></stock>
<stock><sku>PAD-02</sku><item>Note pad</item><units>15</units><unit_cost>2</unit_cost></stock>
<stock><sku>BOX-03</sku><item>Storage box</item><units>6</units><unit_cost>4.75</unit_cost></stock>
</inventory>
You can instead copy each block into a plain-text editor and save it as UTF-8 with the stated extension. Do not copy the code fences or add a .txt suffix. The examples deliberately avoid nested collections, dates, nulls, namespaces and attributes. XML element text is not an explicit numeric type declaration; JSON’s unquoted numbers likewise do not prove how Calc stored the imported cells.
Open each file, without mapping cells
- In Calc choose File → Open, select
stock-records.json, and click Open. - Inspect the resulting document before adding formulas. Find the table containing
sku,item,unitsandunit_cost. - Repeat File → Open for
stock-records.xml. Check this result independently rather than assuming it matches the JSON import.
The JSON and XML opening help describes automatic mapping of tabular sections, called linkable ranges. Multiple discovered ranges can produce separate sheets. Detection is best effort, not a promise that every syntactically valid file becomes the table you intended. Do not assume a fixed sheet name, column order or header location.
If a file is not recognized automatically, inspect the Open dialog’s file-type choice. The official filter list names JSON Document (Calc) and XML Document (Calc). For this generic XML fixture, do not substitute Flat XML ODF Spreadsheet or Microsoft Excel 2003 XML merely because they also mention XML. If the appropriate filter is absent in your build, stop this exercise there; renaming the file does not add an import filter.
Verify pairings before totals
For each opened file, locate exactly these three records:
| sku | item | units | unit_cost | Expected units × unit_cost |
|---|---|---|---|---|
| KIT-01 | Repair kit | 8 | 12.5 | 100 |
| PAD-02 | Note pad | 15 | 2 | 30 |
| BOX-03 | Storage box | 6 | 4.75 | 28.5 |
This is a target-data table, not a screenshot or a certified imported layout. Verify the four source fields stay paired on each record. Reordered columns are not a failure; a quantity assigned to the wrong SKU is.
If the observed table occupies A1:D4 in the order above, use an empty area for these checks. Otherwise adjust the references to the actual fields and data rows, excluding headers.
| Check | Formula for the stated layout | Expected |
|---|---|---|
| Numeric quantities | =COUNT(C2:C4) |
3 |
| Numeric costs | =COUNT(D2:D4) |
3 |
| Total quantity | =SUM(C2:C4) |
29 |
| KIT-01 extended cost | =C2*D2 |
100 |
| All extended costs | =C2*D2+C3*D3+C4*D4 |
158.5 |
The independent checks are 8 + 15 + 6 = 29 and 100 + 30 + 28.5 = 158.5. Check both numeric counts even if multiplication appears to work: coercion in a calculation is not evidence of the stored cell type. If either count is below 3, inspect the affected cells and follow numbers stored as text on a working copy. Preserve the SKU strings. A locale may display 12.5 as 12,5; compare numeric value, not the decimal separator alone.
Also count three distinct SKUs and check each item’s quantity and cost. An aggregate can match accidentally when errors cancel out.
Keep an editable snapshot, not an assumed feed
After both results pass, save them as separate ODS working copies, such as stock-json-checked.ods and stock-xml-checked.ods. Preserve the original files. Close and reopen the ODS copies, then recheck the records and formulas. This is your acceptance test, not a save/reopen test performed for this tutorial.
For a controlled second import, make a new source copy with only BOX-03’s quantity changed from 6 to 9. Open that source copy as another document. Its expected quantity total is 32, BOX-03 extended cost 42.75, and combined extended cost 172.75. Keep the first checked copy unchanged so the two source revisions cannot be confused.
The term linkable range describes a tabular section recognized by the importer; it is not sufficient evidence of an ongoing refresh connection. Do not expect editing a JSON/XML file to update an already saved ODS snapshot. For deliberate refresh workflows, see linked external data tables.
If the output is incomplete or unexpected
- Raw text or the wrong application appears: return to Calc’s Open dialog and check the extension and Calc filter. Do not treat a text display as a successful table import.
- Missing records or extra sheets: inspect every sheet and compare against the three SKU pairs. Keep the original export; do not delete unexpected output until you know what it represents.
- Valid XML does not form a useful table: syntax validity and tabular detectability are different. For controlled element selection, use the existing XML Source mapping tutorial. Do not apply its mapped-cell instructions inside File → Open.
- A nested production export behaves differently: reduce a copy to a small representative sample and specify the intended rows and columns before accepting any result. This flat fixture does not establish handling of nested arrays, optional fields or mixed types.
Calc Guide 26.2, Chapter 12 documents direct import separately from XML Source and explicitly warns that automatic mapping can fail. A readable sheet is the start of verification, not the end.