This is a Node.js script that converts Confluence Cloud pages into Markdown format.
It uses Confluence Cloud v2/API to extract pages and their attachments.
It's based on Turndown to help convert Confluence pages to Markdown.
You can run the script through a terminal or command prompt in your computer.
Note: Most tables are now automatically converted to Markdown format, but there are a few that, for some reason, are returned as HTML tables.
- Node.js installed on your computer.
- Confluence Cloud access: username (email) and password.
- Obtain a Confluence API token
- Create a folder in your computer to store the Confluence-to-Markdown Converter files.
- Choose any method to copy the files in this repository into the folder in your computer.
- Open a terminal and ensure that you are on the folder where the files are now stored.
- From the terminal, run the following command to install external libraries:
npm install- Use a text editor to create a
config.tomlfile. - Obtain the following data:
- Confluence username (email)
- Confluence API token
- Base URL of the pages you will be extracting in the corresponding lines.
- Insert the data in the
config.tomlfile following this structure:
username = "name@company.com"
password = "YOUR_API_TOKEN"
base_url = "https://company.atlassian.net/wiki"- Save the
config.tomlfile in the folder the Confluence-to-Markdown Converter is stored on you computer.
-
From the terminal, and within the program's folder, run the following command:
node conf2md.js
-
When prompted, insert the Confluence page ID number of each the pages you wish to convert and press Enter after each one (press Enter with no value to finish).
Note: The ID number is found in the the URl of Confluence page you want to convert.
-
The program automatically creates the
./importsfolder and stores in it the newly created markdown files. -
You will find all attachments in the
./imports/mediafolder.
-
From the terminal, and withing the program's folder, run the following command:
node conf2mdBySpace.js
-
When prompted, type the Confluence space key and press Enter.
Note: The Confluence space key is automatically generated that can be found in Space settings > Space details > Key.
You can also find the key in the Confluence space's URL. it's a set of capital letters resembleing the initials of the space name. -
The script will automatically store the converted pages in
./importsfolder. -
You will find all the attachments i the
./imports/mediafolder.