Back to blog
5 min read Import Guides

Import HTML Content into WordPress Without Breaking Formatting

When you move articles from another CMS, a static site or a content export, the body text usually arrives as HTML: headings, tables, images, embedded videos, sometimes block markup from another WordPress site. The worry is that the import will flatten it, strip the table or leave the images pointing at the old server. With Import Export by RockStarLab the HTML goes into the post as it is, and the images in it are downloaded to your Media Library. Two articles for a coffee roastery’s blog go through the import below, and we check what came through.

Free: everything in this guide works in the free plugin.

Short Answer

  1. Put the HTML of each post in one cell of a CSV or Excel file. In CSV, the cell must be in double quotes, and quotes inside the HTML doubled.
  2. Go to Import Export by RockStarLab → Import, choose Posts and map the HTML column to Content.
  3. Keep Automatically Import Media Files on, so images in the HTML are downloaded and their links updated.
  4. Run the import as an administrator.

The file

The first article is plain HTML with a heading, a table with a class and inline style, an image on the old site, a YouTube embed and a small script. The second is block markup copied from another WordPress site. Both bodies span several lines. In CSV that’s fine as long as the cell is quoted; spreadsheet programs and most export tools do this for you:

Title,Content,Status
How Our Coffee Is Processed,"<h2>Washed, natural and honey</h2>
<p>Processing decides much of what you taste. …</p>
<table class=""compare"" style=""width:100%"">
…
<p><img src=""https://old.example-roastery.com/wp-content/uploads/old-blog/drying-beds.jpg"" alt=""Coffee cherries on raised drying beds"" width=""1200"" height=""800""></p>
<iframe width=""560"" height=""315"" src=""https://www.youtube-nocookie.com/embed/…"" allowfullscreen></iframe>
<script>console.log(""tracking"");</script>",publish
Brewing Ratios Cheat Sheet,"<!-- wp:heading -->
<h2 class=""wp-block-heading"">Ratios we use</h2>
<!-- /wp:heading --> …",publish

If you build the file in Excel or Google Sheets, paste the HTML into the cell and save as CSV or XLSX; you don’t need to escape anything by hand. Excel cells hold up to 32,767 characters, so very long articles are safer in a CSV made by a script or in JSON.

Map and import

Auto Map matched Title, Content and Status. On the options step, Automatically Import Media Files is on by default. Both posts were imported in 2 seconds.

What came through

Imported post How Our Coffee Is Processed on the site: heading, a comparison table of washed, natural and honey processing, and the coffee drying beds image
The heading, table and image came through as in the file.
  • Headings, paragraphs and the table are exactly as in the file, including the table’s class and inline style.
  • The image was downloaded to the Media Library, attached to the post, and its src now points to the new site. The alt text, width and height stayed.
  • The YouTube iframe was kept in the content.
  • The script was kept too, because the import ran as an administrator who is allowed to publish unfiltered HTML.

The block markup became real blocks. The editor shows a Heading and a List block, not a single Classic block:

Block editor for Brewing Ratios Cheat Sheet with List View showing an H2 Ratios we use block and a List block
Block markup in the file becomes real blocks.

Plain HTML without block comments opens in the editor as a Classic block. It displays correctly; if you want blocks, open it and choose Convert to blocks.

Who may import scripts and iframes

WordPress lets only some users save unfiltered HTML. On a single site that’s Administrators and Editors; on a Multisite network, only Super Admins. When someone else runs the import, the content is filtered the same way as in the editor: scripts and other tags WordPress doesn’t allow for that user are removed. If an embed disappears, check who ran the import.

Common formatting problems and fixes

  • Text cut off or columns shifted. A quote inside the HTML wasn’t doubled, so the CSV ended the cell early. Re-save the file from a spreadsheet, or export it as XLSX or JSON instead.
  • Accented letters look wrong. The file isn’t UTF-8. See fixing broken characters in CSV files.
  • Images still load from the old site. Automatically Import Media Files was off, or the old site blocks downloads. Turn the option on and import again with Update by Title.
  • Links point to the old domain. Use Replace links on the options step to rewrite old-domain.com to your new domain during the import.

Before you import

Imported HTML goes straight onto your pages, including any script it contains. Check content from unknown sources, back up the site and import a couple of rows first.

With an AI agent

An AI agent connected through the WordPress MCP Adapter (see connecting Claude Code to WordPress) can check that nothing was stripped:

Show me the saved HTML of the post "How Our Coffee Is Processed".

In our run, the agent called rsl-ie/export-preview for posts with the title and content fields. It returned the content with the table, the image on the new site’s URL, the iframe and the script, the same as in the file.

FAQ

Does the import convert HTML to blocks?

No. Block markup stays blocks; plain HTML opens as a Classic block, which you can convert in the editor.

Are images inside the content imported?

Yes, with Automatically Import Media Files on. The links in the HTML are updated to the new files.

Why was my script or iframe removed?

The user who ran the import isn’t allowed to publish unfiltered HTML. Run it as an Administrator, or a Super Admin on Multisite.

Can I import HTML from Excel?

Yes. Paste the HTML into a cell and save as XLSX or CSV. Very long articles may exceed Excel’s cell limit.

Can I import Elementor or page builder content?

Page builders keep their layout in custom fields, not only in the HTML. Export and import those fields together with the content.

Get the free plugin on WordPress.org.

Dmitriy
About author

Dmitriy

WordPress Developer with 15+ years of commercial experience. Elite Author on ThemeForest and creator of custom WordPress plugins. Passionate about clean code, performance optimization, and building useful tools for the WordPress community.

JOIN THE CONVERSATION

Comments 0

Have a question or a tip to share? Leave it below.

Leave a comment

Your email address will not be published. Required fields are marked *

We store your name, email and comment to show and moderate it; your email is never published. Spam protection is provided by Cloudflare Turnstile and profile pictures by Gravatar. See our Privacy Policy.


Try the plugin with no risks!

New users get 1 month with access to all premium features. Experience the most powerful WordPress data engine today.

Download Now
Get PRO for FREE