# Web Page to JSON & JSON-LD Extractor (`miacx/page-to-json`) Actor

Extract JSON-LD, page metadata, Markdown, links and images from public URLs. Add fields using CSS selectors or regex. Reads HTML without a browser.

- **URL**: https://apify.com/miacx/page-to-json.md
- **Developed by:** [mia.cx](https://apify.com/miacx) (community)
- **Categories:** Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.45 / 1,000 pages

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Web Page to JSON & JSON-LD Extractor

Read a page's structured data without making your agent parse its HTML.
Send public URLs for JSON-LD, metadata, main-content Markdown, links and images, plus optional CSS or regex fields.
Each successful page costs $0.00045, plus $0.00005 per run start at default memory.
The Actor reads HTML without a browser or runtime LLM calls.

### Try it

```json
{"urls":["https://github.com/apify/crawlee"]}
```

An empty input `{}` extracts the same page. No upstream API key is needed.

### Use from an agent

Add `https://mcp.apify.com?tools=miacx/page-to-json` to your MCP client and sign in to Apify.
Call the dedicated Actor tool, then use `get-dataset-items` to read the completed run's dataset.
Or set `APIFY_TOKEN` to your Apify API token and call the API for JSON rows:

```sh
curl --fail-with-body 'https://api.apify.com/v2/actors/miacx~page-to-json/run-sync-get-dataset-items' \
  -H "Authorization: Bearer $APIFY_TOKEN" -H 'Content-Type: application/json' \
  -d '{"urls":["https://github.com/apify/crawlee"]}'
```

### What you get

The dataset contains one row per unique canonical URL, including failed pages.
Read `status` first. On `ok`, inspect `data`; otherwise read `error`.
Successful rows can have `data.warnings`, `data.truncated` or `data.fieldErrors` and still incur a Page event.

Selected fields from replaying the synthetic `test/fixtures/article.html` fixture:

```json
{
  "url": "https://gazette.example/news/solar-co-ops",
  "status": "ok",
  "ok": true,
  "data": {
    "title": "Solar Co-ops Are Rewiring Small Towns | The Commons Gazette",
    "lang": "en-GB",
    "canonical": "https://gazette.example/news/solar-co-ops",
    "jsonLd": [{
      "@context": "https://schema.org",
      "@type": "NewsArticle",
      "headline": "Solar Co-ops Are Rewiring Small Towns",
      "datePublished": "2026-10-30T08:00:00Z",
      "author": {"@type": "Person", "name": "Rhiannon Price"}
    }]
  }
}
```

Successful rows include `fetchedAt` and `source` with final URL, HTTP status, content type, redirects and cache state.
`fetchedAt` is the original fetch time, retained on cache hits.
Failed rows omit `data`, `source` and `fetchedAt`.

`data` contains `title`, `lang`, `canonical`, `meta`, `openGraph`, `twitter`, `jsonLd`, `microdata` and `rdfa`.
It also contains headings, `content.markdown`, `content.wordCount`, links and images.
Missing title, language and canonical values are null; missing maps and arrays are empty.
Repeated metadata keys become arrays. Microdata and RDFa resources contain `type`, `id` and `properties`.

Custom fields appear under `data.fields`. No match returns null, or an empty array with `all: true`.
Invalid specs and failed conversions appear in `data.fieldErrors`; other page data remains available.

### Input

| Field | Default | Accepted input |
| --- | --- | --- |
| `urls` | `["https://github.com/apify/crawlee"]` | Nonempty array, up to 1,000 distinct input entries. Public HTTP(S) URLs, at most 2,048 characters each. |
| `extract` | `{}` | Up to 50 field names mapped to CSS strings or field-spec objects. Omitted adds no custom fields. |

Fragments are removed before page deduplication.
A field can be a selector string, such as `{"headline":"h1"}`, or an object:

```json
{
  "urls": ["https://github.com/apify/crawlee"],
  "extract": {
    "headline": "h1",
    "links": {"selector": "main a", "attribute": "href", "type": "url", "all": true}
  }
}
```

Field objects accept `selector`, optional `attribute`, `regex`, `type` and `all`.
Types are `string` (default), `number`, `integer`, `boolean` or `url`.
RE2 regex keeps capture group 1, or the whole match when no group exists.
Selectors allow at most 300 characters and 32 parts; `:has`, `~` and `:nth-*` are unsupported.
`all: true` returns at most 100 matches.

### Pricing

One Page event costs $0.00045, including metadata and caller fields.
Ten successful pages cost $0.00455, including $0.00005 per run start at default 256 MB memory.
One thousand Page events cost $0.45, plus run starts.

Truncated pages, field errors and pages with no structured data still count when extraction succeeds.
Failed pages incur no Page events. Canonical duplicates incur no additional Page events within the run.
Cached pages still count. The $0.00005 run start applies even with no billable pages at default memory.
Apify counts one start event per GB of memory, with a minimum of one event.

### Limits and data freshness

- The Actor processes up to 1,000 distinct input entries, with five pages in flight.
- HTML reads stop at 2 MiB; the retained prefix is parsed. DOM limits are 50,000 nodes and 256 retained nesting levels.
- Markdown caps at 100,000 characters. Links, images and headings cap at 1,000, 500 and 500.
- JSON-LD caps at 50 blocks, 200,000 characters per block and depth 64. Microdata and RDFa each cap at 100 items.
- HTML extraction runs no scripts. Main-content selection can miss sibling containers; RDFa support covers RDFa Lite.

Read `data.truncated` for limits that shortened output.
The Actor uses a per-run memory cache, honoring cache restrictions and freshness up to one hour.
There is no persistent cross-run HTML cache.
Robots policy applies to each URL and redirect, including cache hits. Private destinations are blocked.

### If a row fails

| Status | Next step |
| --- | --- |
| `invalid_url`, `blocked_url` | Supply an absolute public HTTP(S) URL without credentials. |
| `robots_denied`, `robots_unavailable` | Check robots policy or retry once it is available. |
| `fetch_failed`, `timeout`, `http_error` | Inspect `error`; HTTP failures include the response status. |
| `too_many_redirects`, `unsupported_content_type` | Supply the final HTML page URL. |
| `charge_limit_reached` | Increase the run charge limit or reduce the batch. |
| `internal_error` | Keep the error and run ID for investigation. |

For batches exceeding the synchronous API's 300-second wait, use [asynchronous runs](https://docs.apify.com/api/v2/actor-runs-post).

# Actor input Schema

## `urls` (type: `array`):

Public HTTP(S) page URLs, up to 1,000 distinct input entries per run. Omitted uses https://github.com/apify/crawlee; \[] is invalid. Canonical URLs, including fragment variants, share one result and Page event within the run. Fetches HTML without rendering scripts and respects robots.txt.

## `extract` (type: `object`):

Up to 50 named fields, e.g. {"headline":"h1"}. Values are CSS selector strings or objects with selector, attribute?, regex? (RE2), type? (string, number, integer, boolean, url), all?. Default {} adds no fields. No match returns null, or \[] with all: true. Invalid fields appear in fieldErrors; the page can still be billable.

## Actor input object example

```json
{
  "urls": [
    "https://example.com/"
  ],
  "extract": {
    "headline": "h1",
    "price": {
      "selector": ".price",
      "regex": "([0-9.,]+)",
      "type": "number"
    }
  }
}
```

# Actor output Schema

## `results` (type: `string`):

One row per item, each with a status field.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://example.com/"
    ],
    "extract": {
        "headline": "h1",
        "price": {
            "selector": ".price",
            "regex": "([0-9.,]+)",
            "type": "number"
        }
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("miacx/page-to-json").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "urls": ["https://example.com/"],
    "extract": {
        "headline": "h1",
        "price": {
            "selector": ".price",
            "regex": "([0-9.,]+)",
            "type": "number",
        },
    },
}

# Run the Actor and wait for it to finish
run = client.actor("miacx/page-to-json").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://example.com/"
  ],
  "extract": {
    "headline": "h1",
    "price": {
      "selector": ".price",
      "regex": "([0-9.,]+)",
      "type": "number"
    }
  }
}' |
apify call miacx/page-to-json --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,miacx/page-to-json"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/WMjKtVRFDjWlgxSQa/builds/feLXkFkeCvHEAcW6m/openapi.json
