@kklab/json2markdown
TypeScript icon, indicating that this package has built-in type declarations

0.0.17 • Public • Published

json2markdown

A simple JSON to Markdown converter that transforms JSON data into easily readable text.

Usage

Using with ES Modules

Import the module and use it in your code:

import { Converter } from '@kklab/json2markdown';

const output = Converter.toMarkdown({
  'Hello, World!': 'It works!',
}, {
  onConvert: (element) => {
    if (element.tag === 'heading') {
      element.level += 1;
    }
    return element;
  },
});

console.log(output);
// Output:
// ## Hello, World!\n\nIt works!\n\n

Using with UMD Modules

Include the UMD script in your HTML file and use it:

<script src="https://unpkg.com/@kklab/json2markdown/dist/index.umd.js"></script>
<script>
const output = window.JSON2MD.Converter.toMarkdown({
  'Hello, World!': 'It works!',
}, {
  onConvert: (element) => {
    if (element.tag === 'heading') {
      element.level += 1;
    }
    return element;
  },
});

console.log(JSON.stringify(output));
// Output:
// ## Hello, World!\n\nIt works!\n\n
</script>

Development

To start a local development server, run:

npm run dev

Testing

To run the tests for this package, run:

npm run test

Readme

Keywords

Package Sidebar

Install

npm i @kklab/json2markdown

Weekly Downloads

62

Version

0.0.17

License

MIT

Unpacked Size

11.9 kB

Total Files

13

Last publish

Collaborators

  • williamchou