Skip to content

How to generate Product structured data (JSON-LD) from a CSV file

From a spreadsheet of products to one JSON-LD block per product page, with the fields Google asks for checked before anything goes live.

We make Schema Markup Generator, the app this guide uses. The free methods come first; every step shown in Schema Markup Generator was checked in the app itself, and the screenshots come from the real app with invented sample data.

Short answer

Keep one row per product page in a spreadsheet, generate one JSON-LD block per row, and check every row against the properties Google requires before you export: for a merchant listing, the product's name and image and an offer with a price above zero and a currency. Paste each block into its own page, then test a few pages with Google's Rich Results Test. Valid markup makes a page eligible; Google does not promise a rich result.

What Google asks for

Google's introduction to Product structured data describes two kinds of result: product snippets and merchant listings. Their required properties, as listed on Google's pages:

Result Required
Merchant listing name, image, and offers as an Offer with price (above zero) and priceCurrency (a three-letter ISO 4217 code)
Product snippet name, and one of review, aggregateRating or offers

Two rules from Google's general structured data guidelines matter as much as the fields: mark up only what visitors can see on the page, and do not count on the markup showing in search results, which Google decides. In practice, the price and availability in the JSON-LD must be the ones on the page, and ratings or reviews belong in the markup only when the page really shows them. The property names come from schema.org/Product and schema.org/Offer.

Prepare the spreadsheet

One row per product page, one column per property. The examples below use these columns, separated by semicolons and saved as UTF-8:

sku;name;image;price;currency;availability;url;brand
HL-100;Espresso cup;https://shop.example/img/hl-100.jpg;12.50;EUR;in stock;https://shop.example/p/HL-100;Harbour Lane
HL-101;Café au lait bowl;https://shop.example/img/hl-101.jpg;18,90;EUR;in stock;https://shop.example/p/HL-101;Harbour Lane
HL-102;Tea pot "Łódź";https://shop.example/img/hl-102.jpg;;EUR;out of stock;https://shop.example/p/HL-102;Harbour Lane
  • image and url: full addresses, starting with https://.
  • price: a number without the currency sign. Schema.org's price property asks for a dot as the decimal mark, so 18,90 has to become 18.90.
  • currency: the ISO 4217 code, such as EUR or USD.
  • availability: one word list you keep to (here: in stock, out of stock, preorder), turned into schema.org values such as https://schema.org/InStock.

Method 1 (free): a short Python script

Python is free from python.org; this script uses only its standard library, so there is nothing else to install. Save it as products_to_jsonld.py next to the CSV and run py products_to_jsonld.py products.csv. It was tested with Python 3.11 on Windows on 30 November 2026.

import csv, json, re, sys
from pathlib import Path

AVAILABILITY = {"in stock": "InStock", "out of stock": "OutOfStock", "preorder": "PreOrder"}
src = Path(sys.argv[1])
out = src.with_name(src.stem + " json-ld")
out.mkdir()  # stops if the folder already exists: nothing is overwritten

with src.open(encoding="utf-8-sig", newline="") as f:
    rows = list(csv.DictReader(f, delimiter=";"))

for line, row in enumerate(rows, start=2):
    row = {k: (v or "").strip() for k, v in row.items()}
    price = row["price"].replace(",", ".")
    problems = [k for k in ("sku", "name", "image", "url") if not row[k]]
    if not re.fullmatch(r"\d+(\.\d+)?", price) or float(price) <= 0:
        problems.append("price must be a number above zero")
    if not re.fullmatch(r"[A-Za-z]{3}", row["currency"]):
        problems.append("currency must be a 3-letter ISO 4217 code")
    if row["availability"].lower() not in AVAILABILITY:
        problems.append("availability must be one of: " + ", ".join(AVAILABILITY))
    if problems:
        print(f"row {line} ({row['sku'] or 'no SKU'}): skipped, " + "; ".join(problems))
        continue
    product = {
        "@context": "https://schema.org",
        "@type": "Product",
        "name": row["name"],
        "image": [row["image"]],
        "sku": row["sku"],
        "offers": {
            "@type": "Offer",
            "url": row["url"],
            "price": price,
            "priceCurrency": row["currency"].upper(),
            "availability": "https://schema.org/" + AVAILABILITY[row["availability"].lower()],
        },
    }
    if row.get("brand"):
        product["brand"] = {"@type": "Brand", "name": row["brand"]}
    text = json.dumps(product, ensure_ascii=False, indent=2).replace("</", "<\\/")
    name = re.sub(r"[^\w.-]", "_", row["sku"]) + ".html"
    (out / name).write_text(f'<script type="application/ld+json">\n{text}\n</script>\n', encoding="utf-8")
    print(f"row {line} ({row['sku']}): {name}")

On the three rows above plus a fourth, it printed:

row 2 (HL-100): HL-100.html
row 3 (HL-101): HL-101.html
row 4 (HL-102): skipped, price must be a number above zero
row 5 (HL-103): HL-103.html

Each file holds one <script type="application/ld+json"> block, and a row with a problem is reported instead of exported. The script writes <\/ wherever the text contains </: it means the same in JSON, and a product name that happens to contain </script> can then never end the block early (we tested one). It covers the required properties only; add columns for the others you use, such as gtin13 or description.

Method 2: Schema Markup Generator, with every row checked

Schema Markup Generator is our Windows app for structured data. It runs offline; the screenshots below come from version 1.0.0 with invented products.

  1. Open the CSV in the From CSV view and choose what each row is (Product here). The encoding and the separator are shown.
  2. Map the fields to the columns. Required fields are marked; the columns can be matched by their names.
  3. Read the preview. Each row shows whether it is ready and, if not, what to fix, before anything is exported.
  4. Export. Each row becomes one .html file with its script block, in a new folder, with all the items in one JSON file and a report.csv listing every row's problems. The CSV is only read.
Schema Markup Generator From CSV view: a products file of 4 rows mapped to Product fields, with 3 of 4 rows ready for a merchant listing and one row whose offer price needs fixing.
From a CSV: one snippet per row, with each row's status before export; here 3 of 4 rows are ready. Schema Markup Generator 1.0.0, captured on 27 November 2026, invented products.

The checks follow Google's rules as the app states them (dated 6 November 2026 in the screenshot), and the app says it in so many words: meeting them makes a page eligible, and Google never promises a rich result. For a single product, the Create view shows the same checks field by field, including warnings for recommended properties.

The Create view for one product: the form, the JSON-LD script block it produces, and the status ready for merchant listings and product snippets, with one warning to add a description.
One product checked against Google's rules for merchant listings and product snippets, with one recommended property missing. Schema Markup Generator 1.0.0, captured on 27 November 2026.
How to Create JSON-LD Schema Markup Without Writing JSON by Hand0:56Watch on YouTubeNothing loads from YouTube until you press play. The player then loads from youtube-nocookie.com, YouTube's privacy-enhanced mode, and connects to Google's servers. Privacy

Paste each block and test it

  1. Paste each block into the HTML of its own product page, not into a list page.
  2. Test the published page, or the code, with Google's Rich Results Test. It shows which rich results the page can have and what is missing.
  3. For the schema.org syntax in general, the Schema Markup Validator reads the same code.
  4. When a price or availability changes on the page, change the row and generate that page's block again: neither method updates prices by itself.

Limitations

  • No tool can promise a rich result: Google decides what to show, and the markup only makes a page eligible.
  • The script checks the required properties and the formats above, nothing else; Google's pages list many more optional properties.
  • Schema Markup Generator checks offline against the rules it was built with, so a change Google makes later is not in them until the app is updated; it does not run Google's test for you. It runs on Windows 10 (22H2) or 11, 64-bit.

References