How to Import WordPress XML into Contentful?
Contentful cannot read a WordPress XML file directly. Export WXR, transform it to import JSON with a tested Node script, then run contentful space import.

You cannot upload a WordPress XML file straight into Contentful. Contentful has no WordPress importer that reads the WXR file you get from Tools > Export, so the job always has three parts: export from WordPress, transform the XML into the JSON format Contentful’s import tool expects, then load it with contentful space import. The transform step is where your content model, rich text and images get decided, and it is where most migrations go wrong.
This guide walks through all three parts with a working script. Our team checked every command and package against the official Contentful repositories and npm on 18 November 2026: Contentful CLI 4.0.14, contentful-import 10.6.0, contentful-migration 5.1.1 and @contentful/rich-text-from-markdown 16.2.2. All three Contentful tools now require Node.js 22 or newer. We ran the transform script on a sample WXR 1.2 export and validated its rich text output with Contentful’s own validator. We did not run the final import against a paid Contentful space, so treat the last step as the documented route and test it on a sandbox environment first.
This page has no Search Console queries recorded yet, so the headings follow the questions people ask when they plan this move.
Can you import a WordPress XML file into Contentful directly?
No. Contentful’s import tool reads a JSON file with a fixed shape (content types, entries, assets, locales and a few other keys). A WordPress export is an RSS-based XML file with WordPress-specific tags. Nothing in between converts one into the other for you.
Contentful did publish a WordPress exporter years ago. The wordpress-exporter.rb repository on GitHub was a Ruby adapter for pulling data out of WordPress, and it has been archived since its last push in January 2018. We could not find a maintained official replacement. Contentful’s own WordPress migration resource is a planning guide, not a tool.
So the realistic options are:
Route | What it involves | Good fit for |
|---|---|---|
Script it yourself (this guide) | Parse WXR, map fields, convert HTML to rich text, write a JSON file, run | Blogs and content sites up to tens of thousands of posts, teams with one developer |
Pull from the WordPress REST API instead of WXR | Same transform, but read | Live sites where you want rendered HTML and resolved featured image URLs |
Write straight to the Content Management API | Use the contentful-management SDK to create and publish each entry | Ongoing sync, or very custom logic per entry |
Hire an agency or migration service | They run the same steps with their own tooling | Large sites with many custom post types and fields |
Whichever route you pick, the JSON file and the content model are the same. The rest of this guide uses the first route because it is the easiest one to review, rerun and version control.
What is in a WordPress XML export file?
The file WordPress gives you is a WXR file, short for WordPress eXtended RSS. The Tools Export screen documentation lists what goes in: posts, pages, custom post types, comments, custom fields, categories, tags, custom taxonomies and users. Each post is an <item> element with fields such as:
titleandwp:post_name(the slug)content:encoded, the raw post content, including Gutenberg block comments and any shortcodesexcerpt:encodedwp:post_date_gmt,wp:statusandwp:post_typecategoryelements, with adomainattribute ofcategoryorpost_tagwp:postmetapairs, including_thumbnail_idfor the featured image and every custom field
What it does not contain is your media files. Images and PDFs appear as separate attachment items with a wp:attachment_url pointing at your server. Contentful has to fetch every file from that URL during import, which matters a lot later.
How do you export WordPress content for Contentful?
From the dashboard: go to Tools > Export, choose All content (or Posts with filters), then click Download Export File. On a big site, use WP-CLI instead, because the browser export can time out. Checked on 18 November 2026 against the wp export command reference:
# Export published posts and their media items into ./wxr
wp export --dir=./wxr --post_type=post,attachment --post_status=publish --max_file_size=50
# Only part of the site? Filter by date and skip comments
wp export --dir=./wxr --post_type=post --start_date=2025-01-01 --skip_commentsBy default wp export splits output into 15 MB files; --max_file_size=-1 writes one file of any size. If you filter by post ID with --post__in, add --with_attachments or the media items are left out. Take a full backup before any of this; our roundup of WordPress backup plugins covers the options if you do not already have one running.
How do you map WordPress content to a Contentful content model?
Decide the model before you write any transform code. WordPress gives every post the same shape: a title, one big HTML body and loose custom fields. Contentful expects you to define content types with typed fields, and the import fails on any field that does not exist in the model.
A practical starting map for a blog:
WordPress source | Contentful field | Field type |
|---|---|---|
| title | Symbol (short text, 256 characters max) |
| slug | Symbol with a unique validation |
| publishDate | Date |
| excerpt | Text (long text) |
| body | RichText |
| featuredImage | Link to an Asset |
| tags | Array of Symbol |
| legacyId | Integer, handy for redirects and reruns |
Categories can be a list of symbols too, or a separate category content type linked from each post if you want category pages with their own fields. Authors work the same way. Keep the first pass simple and add references later; Contentful’s migration tool can change the model after content exists.
How do you create the content model as code?
Use contentful-migration rather than clicking fields together in the web app. The script lives in your repository, so the model is reviewable and you can rebuild it in a fresh environment in seconds. This file creates the model from the table above:
// 01-blog-post-model.cjs - run with: contentful space migration --space-id <SPACE_ID> 01-blog-post-model.cjs
module.exports = function (migration) {
const post = migration
.createContentType('blogPost')
.name('Blog post')
.displayField('title');
post.createField('title').name('Title').type('Symbol').required(true);
post.createField('slug').name('Slug').type('Symbol').required(true).validations([{ unique: true }]);
post.createField('publishDate').name('Publish date').type('Date');
post.createField('excerpt').name('Excerpt').type('Text');
post.createField('body').name('Body').type('RichText');
post.createField('featuredImage').name('Featured image').type('Link').linkType('Asset');
post.createField('tags').name('Tags').type('Array').items({ type: 'Symbol' });
post.createField('legacyId').name('WordPress ID').type('Integer');
};Run it with the CLI. The space migration command applies the script to the master environment unless you pass --environment-id, and asks for confirmation unless you add --yes:
npm install -g contentful-cli
contentful login
contentful space use -s <SPACE_ID>
contentful space migration --space-id <SPACE_ID> --environment-id staging 01-blog-post-model.cjsCreate a separate environment (here called staging) and run everything there first. You can import, check, delete and reimport without touching the environment your live front end reads from.
How do you convert WordPress XML to the JSON Contentful imports?
This is the core of the job. The script below reads a WXR file and writes a JSON file in the shape the contentful-import tool expects: an entries array and an assets array, with every field wrapped in a locale key. It uses three npm packages: fast-xml-parser to read the XML, turndown to turn post HTML into Markdown, and Contentful’s official @contentful/rich-text-from-markdown to turn that Markdown into a rich text document.
npm init -y
npm install fast-xml-parser turndown @contentful/rich-text-from-markdownSave this as wxr-to-contentful.mjs. Checked on 18 November 2026 with Node.js 22 and the package versions named above:
// wxr-to-contentful.mjs - turn a WordPress WXR export into a contentful-import JSON file.
// Usage: node wxr-to-contentful.mjs export.xml content.json
import { readFileSync, writeFileSync } from 'node:fs';
import { XMLParser } from 'fast-xml-parser';
import TurndownService from 'turndown';
import { richTextFromMarkdown } from '@contentful/rich-text-from-markdown';
const [, , input = 'export.xml', output = 'content.json'] = process.argv;
const LOCALE = 'en-US'; // must match your space's default locale
const parser = new XMLParser({ ignoreAttributes: false, parseTagValue: false });
const items = [].concat(parser.parse(readFileSync(input, 'utf8')).rss.channel.item ?? []);
const turndown = new TurndownService({ headingStyle: 'atx', bulletListMarker: '-' });
const text = (v) => (v == null ? '' : String(v));
const meta = (item, key) =>
[].concat(item['wp:postmeta'] ?? []).find((m) => m['wp:meta_key'] === key)?.['wp:meta_value'];
// 1. Attachments become Contentful assets. Contentful fetches each file from its public URL.
const assets = items
.filter((i) => i['wp:post_type'] === 'attachment')
.map((i) => {
const url = text(i['wp:attachment_url']);
const fileName = url.split('/').pop();
const ext = fileName.split('.').pop().toLowerCase();
const types = { jpg: 'image/jpeg', jpeg: 'image/jpeg', png: 'image/png', gif: 'image/gif', webp: 'image/webp', pdf: 'application/pdf' };
return {
sys: { id: `wp-media-${i['wp:post_id']}`, publishedVersion: 1 }, // publishedVersion: the import only publishes items that have it
fields: {
title: { [LOCALE]: text(i.title) || fileName },
file: { [LOCALE]: { contentType: types[ext] ?? 'application/octet-stream', fileName, upload: url } },
},
};
});
// Map each media URL (minus WordPress size suffixes like -1024x768) to its asset id.
const baseUrl = (u) => u.replace(/-\d+x\d+(?=\.\w+$)/, '');
const assetByUrl = new Map(assets.map((a) => [baseUrl(a.fields.file[LOCALE].upload), a.sys.id]));
// 2. Published posts become blogPost entries.
const entries = [];
for (const i of items.filter((x) => x['wp:post_type'] === 'post' && x['wp:status'] === 'publish')) {
const html = text(i['content:encoded']).replace(/<!--[\s\S]*?-->/g, ''); // drop block comments
const markdown = turndown.turndown(html);
// Images that match an exported attachment become embedded assets; anything else is logged, not lost silently.
const body = await richTextFromMarkdown(markdown, (node) => {
const id = node.type === 'image' && assetByUrl.get(baseUrl(node.url));
if (id) return { nodeType: 'embedded-asset-block', data: { target: { sys: { type: 'Link', linkType: 'Asset', id } } }, content: [] };
console.warn(`post ${i['wp:post_id']}: ${node.type} skipped (${node.url ?? ''})`);
return null;
});
const terms = [].concat(i.category ?? []);
const thumb = meta(i, '_thumbnail_id');
const fields = {
title: { [LOCALE]: text(i.title) },
slug: { [LOCALE]: text(i['wp:post_name']) },
publishDate: { [LOCALE]: text(i['wp:post_date_gmt']).replace(' ', 'T') + 'Z' },
excerpt: { [LOCALE]: text(i['excerpt:encoded']) },
body: { [LOCALE]: body },
tags: { [LOCALE]: terms.filter((t) => t['@_domain'] === 'post_tag').map((t) => text(t['#text'])) },
legacyId: { [LOCALE]: Number(i['wp:post_id']) },
};
if (thumb) fields.featuredImage = { [LOCALE]: { sys: { type: 'Link', linkType: 'Asset', id: `wp-media-${thumb}` } } };
entries.push({
sys: { id: `wp-post-${i['wp:post_id']}`, publishedVersion: 1, contentType: { sys: { type: 'Link', linkType: 'ContentType', id: 'blogPost' } } },
fields,
});
}
writeFileSync(output, JSON.stringify({ entries, assets }, null, 2));
console.log(`Wrote ${entries.length} entries and ${assets.length} assets to ${output}`);node wxr-to-contentful.mjs mysite.wordpress.2026-11-18.000.xml content.jsonA few choices in the script are deliberate, so you know what to change:
- Stable IDs. Every entry gets
wp-post-<ID>and every assetwp-media-<ID>. Rerunning the import then updates the same records instead of creating duplicates, and you can always trace a Contentful entry back to its WordPress post. - A publishedVersion on every item. We checked the contentful-import 10.6.0 source: its publish step only publishes entries and assets whose
syscarries apublishedVersion, because the tool was built to copy one space into another. A hand-built file without it imports everything as drafts, even though the progress output shows a tick next to Publishing. The script sets it to 1. - Only published posts. Drafts, revisions and trashed posts are skipped. Change the status filter if you want drafts as Contentful drafts.
- Block comments are stripped before conversion. The
<!-- wp:paragraph -->markers mean nothing outside WordPress. - Tag values are read as text.
parseTagValue: falsestops the XML parser turning a slug like007into the number 7. - The locale must match your space. Change
LOCALEif your default locale is noten-US; the import tool requires the same default locale on both sides.
How does WordPress HTML become Contentful rich text?
Contentful’s RichText field does not store HTML. It stores a JSON document of typed nodes: paragraphs, headings, lists, tables, hyperlinks, embedded entries and embedded assets. Anything that does not fit one of those node types has no place to go.
Contentful maintains converters in its rich-text repository, but look at the direction: there is a Markdown to rich text converter, and rich text to HTML, React and plain text renderers. There is no official HTML to rich text converter. That is why the script goes HTML to Markdown first with turndown, then Markdown to rich text. It is a lossy route on purpose: what survives is the structure that rich text can represent.
Here is what survived when we ran the script on our sample export:
WordPress content | Result in rich text |
|---|---|
Paragraphs, bold, italic, links | Kept as paragraph, text marks and hyperlink nodes |
Headings H2 to H6 | Kept as heading-2 to heading-6 |
Bulleted and numbered lists | Kept as unordered-list and ordered-list |
Images that match an exported attachment | Turned into embedded-asset-block nodes by the script’s fallback |
Images hosted elsewhere | Skipped, with a warning line in the console |
Shortcodes such as | Kept as literal text, which you must find and replace |
Embeds, columns, buttons, custom blocks | Reduced to whatever plain HTML they rendered, or dropped |
Inline styles, classes, custom HTML | Dropped |
The script prints every skipped node with its post ID. Read that log. A handful of warnings is normal; hundreds usually mean a page builder or a heavy block plugin wrote most of the content, and those posts need a different plan (often a “legacy HTML” Text field and a front-end component that renders it as is).
Two size limits also apply. Contentful’s technical limits page caps a rich text field at 200,000 characters and a 1 MB payload, and a whole entry at 2 MB. Very long posts with many embedded nodes can hit that.
How do WordPress images and media move to Contentful?
In the JSON file, each asset has a file field with an upload URL. During import, Contentful downloads the file from that URL and processes it. We confirmed this in the contentful-import 10.6.0 source: if an asset file has no uploadFrom, the tool passes the url or upload value to Contentful to fetch.
That gives you three practical rules:
- The old WordPress site must stay online and publicly reachable until the import finishes. Media behind a login, a maintenance mode page or a firewall rule that blocks unknown bots fails to process.
- Match resized image URLs to the original. WordPress inserts sized copies such as
photo-1024x768.jpginto post content, while the attachment item holdsphoto.jpg. The script strips the size suffix before matching, so the body image links to the right asset. - Check the size limits for your plan. Contentful lists 50 MB per asset on Free plans and 1,000 MB on paid plans, with images capped at 100 MB and filenames at 256 characters.
Assets have their own IDs, so the featured image is just a link: { sys: { type: "Link", linkType: "Asset", id: "wp-media-12" } }. The import tool creates assets before entries, so links resolve as long as both are in the same file.
How do you run the import with the Contentful CLI?
With the model in place and content.json written, the import is one command. These flags come from the space import documentation, checked on 18 November 2026:
# Content only: the model already exists from the migration script
contentful space import \
--space-id <SPACE_ID> \
--environment-id staging \
--content-file content.json \
--skip-content-model \
--error-log-file import-errors.json
# Create everything as drafts so editors can review before publishing
contentful space import --space-id <SPACE_ID> --environment-id staging \
--content-file content.json --skip-content-model --skip-content-publishingUseful options to know:
--skip-content-publishingcreates entries without publishing them.--skip-content-updatesand--skip-asset-updatesonly create new items and leave existing ones alone, useful for a second pass.--retry-limit(default 10) and--timeout(default 20000 ms) control retries.--configtakes a JSON file holding all options, which is easier to keep in version control than a long command.
Expect it to be slow on big sites. Contentful’s Content Management API allows 7 requests per second per space on Free plans and 10 on paid plans, and the import tool defaults to 7. Each entry needs a create and a publish call, and each asset needs create, process and publish. Ten thousand posts with images is a job measured in hours, not minutes.
How do you check the import and keep your SEO?
Open the target environment and compare counts first: number of published posts in WordPress against number of blogPost entries, number of attachments against assets. Then spot check a dozen entries across old and new posts, long and short ones, and posts with galleries or embeds.
Things people forget at this stage:
- URLs. Contentful stores content; it does not serve your pages. Your front end (Next.js, Astro, Nuxt or similar) builds URLs from the
slugfield. Keep the same paths, or set up 301 redirects from every old URL. ThelegacyIdfield makes a redirect map easy to generate. - Internal links inside posts still point at the old domain or old paths. Search the rich text for your old hostname and rewrite those links before launch.
- SEO fields. Yoast or Rank Math titles and descriptions live in
wp:postmeta(for example_yoast_wpseo_title). Add fields for them to the model and map them in the script, or you lose them. - Comments. Contentful has no comment system. Export them separately if you need them, or accept the loss.
- The old site. Once the new site is live and the redirects are tested, retire WordPress properly. If it is hosted on DreamHost, our sister guide on uninstalling WordPress from DreamHost covers what to back up before you delete anything.
One more step if you pulled content through the REST API rather than WXR: once the import is done, the open endpoint has served its purpose. Our guide to locking down XML-RPC and the REST API shows how to close the parts you no longer need on the old install.
Should you use the WordPress REST API instead of the XML file?
Often, yes. The REST API returns posts as JSON, which skips the XML parsing step, and the content.rendered value has shortcodes and dynamic blocks already turned into HTML. You page through /wp-json/wp/v2/posts?per_page=100&page=1 (100 is the maximum per page) and read the X-WP-TotalPages response header to know when to stop.
WXR export file | REST API | |
|---|---|---|
Works on an offline or staging copy | Yes, it is a file | Only if the site runs |
Shortcodes and dynamic blocks | Raw, unrendered | Rendered to HTML |
Custom fields | All postmeta included | Only fields registered for REST |
Drafts and private posts | Included | Needs authentication |
Rerunnable, versioned snapshot | Yes | You save the JSON yourself |
Our team usually takes the export file for the archive and the API for any post whose shortcodes need rendering. The transform code after extraction is the same either way.
Common mistakes people report
These come from open and recent issues on Contentful’s own GitHub repositories, checked on 18 November 2026. They are the problems that actually stop WordPress to Contentful imports.
- The import “fails” on a free organisation even though everything imported. Users report that contentful-import ends with an error saying Timeline (Releases) is not enabled for the organisation, even when all content was imported and published, because the Releases step is reported as an error instead of a warning (contentful-import #1727, November 2026; also #1721). Check the content itself before rerunning anything.
- Rate limit errors on asset-heavy imports. People see repeated “Rate limit error occurred. Waiting before retrying” messages while assets import, and some runs give up after retries (contentful-cli #2870). Smaller batches and a quieter time of day help, since other API traffic on the space shares the same limit.
- Asset processing hangs with no progress. One report traced indefinite hangs to the retry setting being ignored, with no timeout when Contentful never answers the processing request (contentful-import #1632, May 2026). If a run stalls on assets, stop it and rerun; the stable IDs mean finished items are not duplicated.
- “Publishing Content Entries” shows a tick, but entries stay as drafts. Reported in contentful-import #1069, with other users confirming it. In hand-built files the usual cause is a missing
sys.publishedVersion, which the tool uses to decide what to publish; a required field that fails validation has the same effect for single entries. Read the error log file, not just the progress output. - Slow restores at scale. Users note that space import still sends one create, update and publish per item, which makes large imports take a long time, and have asked for bulk operations support (contentful-cli #3331, August 2026). Plan your cutover window around it.
- “Cannot open asset from filesystem” when uploading local files. This happens when
--upload-assetsand--assets-directorypoint at a folder layout the tool does not expect (contentful-import #819). For WordPress media, letting Contentful fetch public URLs avoids this path entirely.
How long does a WordPress to Contentful migration take?
For a typical blog of a few hundred posts with a simple model, our team would plan one to two days of developer time: half a day for the model and script, a few hours of import runs on a sandbox environment, and the rest on checking content, fixing shortcodes and building redirects. The import itself is the quick part.
Time grows with three things: the number of custom post types and fields, how much content came from page builders or block plugins, and how many images each post carries. A site where most pages were built with a visual builder is closer to a rebuild than a migration.
If you are weighing a move in the other direction, our AEM to WordPress migration guide covers the same export, transform and load pattern for an enterprise CMS moving onto WordPress.
Is it worth moving from WordPress to Contentful?
It depends on what you need from the move. Contentful fits teams that publish the same content to a website, an app and other channels, want strict typed content models, and already have developers running a separate front end. In September 2026 Salesforce completed its acquisition of Contentful, according to Salesforce’s own announcement, so expect its roadmap to lean further into the Salesforce platform.
It is a poor fit if your site is a blog or brochure site run by non-developers. You lose the theme, plugins, comments, the visual editor and the one-click publishing WordPress gives you, and you take on a front-end build, hosting and an API bill. WordPress can also run headless itself through the REST API if decoupling the front end is the real goal.
FAQ
Does Contentful have a WordPress import plugin?
No maintained official one. Contentful’s old Ruby exporter is archived on GitHub. You either script the transform, as in this guide, or use a third-party service.
Can I import WordPress pages and custom post types too?
Yes. Change the wp:post_type filter in the script and map each post type to its own Contentful content type. Custom fields come through as wp:postmeta; ACF repeater and flexible content fields are stored serialized and need extra parsing.
Will my WordPress categories and tags carry over?
Only if you map them. The script stores tags as a list of strings. Contentful’s own Tags feature is separate, and the CLI import notes that tags must already exist in the target space.
What happens to my WordPress users and authors?
Entries created by the import are owned by the user whose management token ran it. Original author history does not carry over. Add an author field or an author content type if bylines matter.
Can I run the import more than once?
Yes, as long as entry and asset IDs stay the same between runs. By default the import updates existing items with the same ID; add --skip-content-updates if you only want new ones created.
Which Node.js version do I need?
Node.js 22 or newer. As of 18 November 2026, contentful-cli 4.0.14, contentful-import 10.6.0 and contentful-migration 5.1.1 all declare node >=22 on npm.
Plugins we build and run
We maintain these ourselves, which is why we can support them on your site.
- BuddyNextThe self-hosted community engine for WordPress
- BuddyXFree community theme, Pro when you outgrow it
- ReignPremium community theme. Add pieces, build anything
- JetonomyCommunity forum and Q&A for WordPress
- EventonomyEvents and RSVPs for WordPress communities
- LearnomyCourses and learning communities on WordPress
- ListoraDirectories and listings your members can browse
- SnipShareCode sharing built for developer communities
- WB Ad ManagerAd placements that turn traffic into revenue
- WP Career BoardA job board your community actually uses
- WP Sell ServicesSell services with offers, orders, and payouts
- MediaVersePhotos, video, and media albums for members
- WB GamificationPoints, badges, and rewards that keep members active
- Product RoadmapPublic roadmaps with voting your users trust
- KanbanomyProject management with a client portal, on your own WordPress site


