NodeJS tool to convert public Notion pages to HTML from page ID
MIT License
NodeJS tool to convert public notion pages to HTML.
Also available as public API:
https://notion-page-to-html-api.vercel.app/
Most of the native Notion blocks are currently supported:
Embeds and tables are not supported yet.
It's perfect as content manager system
It's fully customizable
Install it in a NodeJS project using npm
npm install notion-page-to-html
Then, just import it and paste a public Notion page url
const NotionPageToHtml = require('notion-page-to-html');
// using async/await
async function getPage() {
const { title, icon, cover, html } = await NotionPageToHtml.convert("https://www.notion.so/asnunes/Simple-Page-Text-4d64bbc0634d4758befa85c5a3a6c22f");
console.log(title, icon, cover, html);
}
getPage();
cover
is a base64 string from original page cover image. icon
can be an emoji or base64 image based on original page icon. html
is a full html document by default. It has style, body, MathJax and PrismJS CDN scripts by default. You can pass some options to handle html content.
NotionPageToHtml.convert(
'https://www.notion.so/asnunes/Simple-Page-Text-4d64bbc0634d4758befa85c5a3a6c22f',
options,
);
options
is an object with the following keys
Key | Default value | If true |
---|---|---|
excludeCSS |
false | returns html without style tag |
excludeMetadata |
false | returns html without metatags |
excludeScripts |
false | returns html without script tags |
excludeHeaderFromBody |
false | returns html without title, cover and icon inside body |
excludeTitleFromHead |
false | returns html without title tag in head |
bodyContentOnly |
false | returns html body tag content only |
Clone this application
Make sure you have node v14 or higher and then install all dependencies
npm i
Running tests:
npm test
Installing locally in another project:
npm run build
npm pack
Inside your project:
npm i /path/to/tar/gz
Docker approach for testing
make test
We love your feedback! Feel free to:
Just create a GitHub issue or a PR ;)