Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 6.6 — Structured Data
HTML · Example 1 of 2

Read structured data like a search engine

A crawler parses the JSON exactly like this. The grey line under the fake result is what a rich result might add.

Structured data is a JSON-LD block that describes the page's content in schema.org vocabulary (a product with a price, a recipe with a cooking time), so search engines can understand it exactly and may show rich results like stars and prices.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 6 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write a JSON-LD Recipe for "Egg-free pancakes" by Asha, ready in 20 minutes (cook time 10 minutes), making 8 pancakes, with three ingredients.

02

Write a function toJsonLd(data) that returns a string safe to put inside a <script type="application/ld+json">. Test it with { name: "</script>hi" } and log whether the result contains </script.

Explain it without notes

01

What is structured data, and why is JSON-LD the recommended format?

02

What are rich results, and does valid markup guarantee them?

03

Why must structured data match the visible page?

04

How do you safely embed user-provided text in a JSON-LD block?

Read structured data like a search engine

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

Type: Product
Name: Blue Cotton School Bag
Price: 899 INR
In stock: true