npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

n8n-nodes-json-to-pdf

v1.1.1

Published

Convert Markdown/JSON into PDF (single document or e-book) for n8n

Readme

JSON to PDF

A versatile n8n community node that converts JSON payloads (with Markdown formatting) into styled PDF documents—either a single PDF or a full e-book with chapters and table of contents. No external services required.


🚀 Features

  • Two operation modes:

    • Single PDF: treat a JSON field as Markdown text, split on a keyword to insert page breaks.
    • Generate E-book: treat a JSON field as an array of { title, content } chapters, auto-generate a title page, table of contents with links, and chapter formatting.
  • Custom typography:

    • Choose any PDF font (Helvetica, Times-Roman, Courier, etc.).
    • Adjust base font size and line spacing.
  • Page control:

    • In Single PDF mode, specify a “page break keyword” (e.g. ## Chapter) which, when encountered at the start of a line, forces a new page.
    • In E-book mode, control whether each chapter title appears on its own page or inline.
  • Table of Contents (E-book only):

    • Optionally include a TOC with clickable links to each chapter.
    • Customize the TOC title.
  • Error handling:

    • Clear error messages when the JSON field isn’t the expected type.
    • Detailed stack traces available in the n8n execution log.

📦 Installation

  1. In your n8n instance, open Settings → Community Nodes → Install
  2. In npm Package Name enter:

n8n-nodes-free-web-scrapping
  1. Click Install and restart n8n if prompted.

⚙️ Node Configuration

Operation

| Parameter | Description | | ----------- | -------------------------------------------------------------------------------------------------------------------- | | operation | single: render one PDF from a Markdown string. ebook: render an entire e-book from an array of chapters. |

Common Parameters

| Parameter | Type | Default | Description | | ------------- | ------ | ----------- | ------------------------------------------------------------------------------------ | | jsonField | string | data | JSON field that holds either the Markdown string (single) or chapters array (ebook). | | font | string | Helvetica | PDF font name. | | fontSize | number | 12 | Base font size (points). | | lineSpacing | number | 1.15 | Line height multiplier. |

Single PDF Mode

| Parameter | Type | Default | Description | | -------------- | ------ | ------------ | -------------------------------------------------- | | pageBreakKey | string | ## Chapter | Lines starting with this keyword force a new page. |

Example JSON input for “single” mode:

{
  "data": "# Introduction\nThis is text.\n## Chapter 1\nFirst chapter content...\n## Chapter 2\nSecond chapter content..."
}
  • Output: one PDF, with page breaks at each ## Chapter.

Generate E-book Mode

| Parameter | Type | Default | Description | | ------------------- | ------- | ------------------- | -------------------------------------------------------------------------- | | includeToc | boolean | true | Whether to add a “Table of Contents” page. | | tocTitle | string | Table of Contents | Title text for the TOC page. | | chapterTitleStyle | options | newPage | newPage: each chapter title on its own page. inline: title inline. |

Expected JSON structure:

{
  "title": "My Great E-Book",
  "data": [
    { "title": "Chapter 1: Getting Started", "content": "## Hello\nThis is **bold** text..." },
    { "title": "Chapter 2: Advanced Topics",   "content": "More _Markdown_ here..." }
  ]
}
  • The node will:

    1. Insert a title page.
    2. Optionally generate a TOC with links to each chapter.
    3. Iterate each chapter, adding titles and content.

🛠️ Examples

Example 1: Single PDF

  1. Operation: single
  2. JSON Field: data
  3. Page Break Keyword: ## PART

Input JSON:

{
  "data": "# Welcome\nSome intro text.\n## PART One\nContent of part one.\n## PART Two\nContent of part two."
}

Result: PDF with three pages:

  • Page 1: “Welcome” + intro
  • Page 2: “PART One” content
  • Page 3: “PART Two” content

Example 2: Generate E-book

  1. Operation: ebook
  2. JSON Field: data
  3. Include TOC: true
  4. Chapter Title Style: newPage

Input JSON (inbound to the node):

{
  "title": "My Guide",
  "data": [
    {
      "title": "Chapter 1: Beginnings",
      "content": "This is **first** chapter.\nWith multiple lines."
    },
    {
      "title": "Chapter 2: Next Steps",
      "content": "Second chapter _content_."
    }
  ]
}

Result:

  • Page 1: centered “My Guide”
  • Page 2: “Table of Contents” with links to #chapter-1 and #chapter-2
  • Subsequent pages: each chapter on its own page with content rendered from Markdown.

⚠️ Common Errors

Error:

Output
1 item
Field "data" is not an array of chapters
Error details

Other info
n8n version
1.100.1 (Self Hosted)

Stack trace
Error: Field "data" is not an array of chapters
    at ExecuteContext.execute (/…/JsonToPdf.node.js:155:23)
    at WorkflowExecute.runNode (…/workflow-execute.ts:1193:32)
    …
  • Cause: In ebook mode, the node expected jsonField to point at an array of { title, content }, but found something else.

  • Solution: Ensure your JSON conforms to the required structure:

    {
      "data": [ { "title": "...", "content": "..." }, … ]
    }

Error:

Field "data" is not a string
  • Cause: In single mode, the node expected jsonField to be a Markdown string.

  • Solution: Provide a plain string:

    { "data": "# Hello\nSome text…" }

🧑‍💻 Development & Contributing

  1. Clone this repo.

  2. Run npm install.

  3. Edit src/nodes/JsonToPdf/JsonToPdf.node.ts.

  4. Compile: npm run build.

  5. Link locally in n8n:

    cd ~/.n8n/nodes
    ln -s /path/to/n8n-nodes-json-to-pdf dist
  6. Restart n8n and test.


📝 License

MIT © [Threndy]