node package manager


Convert the WordPress XML file to Markdown files.


Support Node of LTS npm version Build Status Document Standard - JavaScript Style Guide

Convert the WordPress XML file to Markdown files.


$ npm install wpxml2md

WordPress XML

Can export the WordPress XML in the following way.

  1. Displays the management screen of WordPress
  2. Select the Tools - Export from the menu
  3. Select All content in Choose what to export
  4. Click to Download Export File


Node API

wpxml2md is promisify function.

const wpxml2md = require('wpxml2md');
wpxml2md('wordpress.xml', 'dest', {report: true})
.then(() => {
} )
.catch((err) => {

Add modes:

const wpxml2md = require('wpxml2md');
wpxml2md('wordpress.xml', 'dest', {noGFM: true, noMELink: true})
.then(() => {
.catch((err) => {
  console.error( err);

wpxml2md( src, dest, [OPTIONS] )

Name Type Description
src String Path of the XML file exported from WordPress.
dest String Destination directory path.
options Object Options.


Name Type Description
noGFM Boolean Disable the Convert the GitHub Flavored Markdown. Default is false, enable a conversion.
noMELink Boolean Disable the Convert the GitHub Extra link on header. Default is false, enable a conversion.
report Boolean Display the process reports. Default is false, disable a report.


Usage: wpxml2md [OPTIONS]
  Convert the WordPress XML file to Markdown files.
    -h, --help    Display this text.
    -v, --version Display the version number.
    -i, --input   Path of the XML file exported from WordPress.
    -o, --output  Path of the output directory.
    -m, --modes   Specify the mode in the comma separated.
                  "no-gfm" is to disable the GitHub Flavored Markdown
                  "no-melink" is to disable the Markdown Extra link on header
    -r, --report  Display the process reports.
                  Default is disable.
    $ wpxml2md -i wordpress.xml -o ./dist -r
    $ wpxml2md -i wordpress.xml -o ./dist -m no-gfm,no-melink -r
  See also:


This section describes the conversion by this tool. Markdown conversion engine was in reference to the design and implementation of the domchristie/to-markdown, rewrite an ES2015 and more.

Output directories

Converted Markdown files are output in the following directory.

├── pages/
│   └── YYYY/
│       └──
└── posts/
    └── YYYY/
  • The name of the root directory is the date time that the execution of the processing
  • The result of converting the Pages will be output to the pages directory
  • The result of converting the Posts will be output to the posts directory
  • Markdown's file name is posted date time.
  • If the file or directory name is a duplicate will be added to the sequential number at the end.


Default markdown.

TAG Markdown
Plain Text Plain text will keep the line breaks and blank lines. It is a specification to enable the WordPress of paragraph function.
<p> \n\nTEXT\n\n
<br> \n
<h1> \n\n# TEXT\n\n, support from h1 to h6.
<h1 id="id"> \n\n# TEXT {#id}\n\n, for Markdown Extra
<hr> \n\n* * *\n\n
<em>, <i> _TEXT_
<strong>, <b> **TEXT**
<code> `TEXT`
<a> [TEXT](URL "ALT")
<img> ![TITLE](URL)
<pre><code> \n\n TEXT\n\n
<blockquote> \n\n> TEXT\n\n
<ul><li> \n\n* TEXT\n\n
<ol><li> \n\n1. TEXT\n\n

GitHub Flavored Markdown.

TAG Markdown
<br> \n
<del>, <s>, <strike> ~~TEXT~~
<ul><li><input type="checkbox"> * [ ] Text, checked is true if [x].
<table> see: Organizing information with tables - User Documentation
<pre><code> \n\n```\nCODE\n```\n\n
<div class="highlight highlight-lang"><pre> \n\n```lang\nCODE\n```\n\n



<a href="example.png" title="Title">
  <img src="example.png" alt="Title"></a>

Remove the short code dregs. Contents will Markdown conversion as HTML.

[![Title](example.png)](example.png "Title")


[code lang="js"]
const test = 'test';
console.log( test );

code is converted to a code block.

const test = 'test';
console.log( test );

Short code of programming languages and converts it to a code block.

const test = 'test';
if( test ) {
  console.log( test );  

For example, the above will be converted to the following.

const test = 'test';
if( test ) {
  console.log( test );  

Language to be converted is the following. The language names are based on the SyntaxHighlighter - Bundled Brushes.

Language Shortcode
Plain Text plain, text
ActionScript3 as3, actionscript3
Bash/shell bash, shell
ColdFusion cf, coldfusion
C# c-sharp, csharp
C++ cpp, c
CSS css
Delphi delphi, pas, pascal
Diff diff, patch
Erlang erl, erlang
Groovy groovy
JavaScript js, jscript, javascript
Java java
JavaFX jfx, javafx
Perl perl, pl
PHP php
PowerShell ps, powershell
Python py, python
Ruby rails, ror, ruby
Scala scala
SQL sql
Visual Basic vb, vbnet
XML xml, xhtml, xslt, html, xhtml