Skip to content

memochou1993/json2markdown-renderer

Repository files navigation

JSON2Markdown Renderer

JSON2Markdown Renderer is designed to convert JSON data into Markdown, making it especially useful for providing a quick overview or for non-developers to read.

Demo

JSON2Markdown Renderer

How It Works

The conversion process begins by using the json2markdown package to parse the JSON data into Markdown, followed by using markdown2html to convert the Markdown into sanitized HTML.

In this process:

  • Objects are converted into headings and content.
  • Arrays are converted into lists.
  • Arrays of objects are converted into tables.
  • Markdown content is preserved.
  • HTML content is sanitized.

The following shows how different types of JSON data appear after being converted into Markdown.

Examples

JSON Object

Heading 3

Heading 4

Heading 5
Heading 6

Hello, World!

JSON Array

  • ♈ Aries
  • ♉ Taurus
  • ♊ Gemini
  • ♋ Cancer
  • ♌ Leo
  • ♍ Virgo
  • ♎ Libra
  • ♏ Scorpius
  • ♐ Sagittarius
  • ♑ Capricorn
  • ♒ Aquarius
  • ♓ Pisces

JSON Array of Objects

Symbol Name Description See Also Metadata
🌑 New Moon A new moon, the first of the eight phases of the moon. 🌘, 🌒
{
"codepoints": "U+1F311",
"shortcodes": [
":new_moon:"
]
}
🌒 Waxing Crescent Moon A waxing crescent moon, the second of the eight phases of the moon. 🌑, 🌓
{
"codepoints": "U+1F312",
"shortcodes": [
":waxing_crescent_moon:"
]
}
🌓 First Quarter Moon A first quarter moon, the third of the eight phases of the moon. 🌒, 🌔
{
"codepoints": "U+1F313",
"shortcodes": [
":first_quarter_moon:"
]
}
🌔 Waxing Gibbous Moon A waxing gibbous moon, the fourth of the eight phases of the moon. 🌓, 🌕
{
"codepoints": "U+1F314",
"shortcodes": [
":waxing_gibbous_moon:"
]
}
🌕 Full Moon A full moon, the fifth of the eight phases of the moon. 🌔, 🌖
{
"codepoints": "U+1F315",
"shortcodes": [
":full_moon:"
]
}
🌖 Waning Gibbous Moon A waning gibbous moon, the sixth of the eight phases of the moon. 🌕, 🌗
{
"codepoints": "U+1F316",
"shortcodes": [
":waning_gibbous_moon:"
]
}
🌗 Last Quarter Moon A last quarter moon, the seventh of the eight phases of the moon. 🌖, 🌘
{
"codepoints": "U+1F317",
"shortcodes": [
":last_quarter_moon:"
]
}
🌘 Waning Crescent Moon A waning crescent moon, the eighth of the eight phases of the moon. 🌗, 🌑
{
"codepoints": "U+1F318",
"shortcodes": [
":waning_crescent_moon:"
]
}

Markdown Code Block

import { Converter as JsonToMarkdownConverter } from '@memochou1993/json2markdown';
import { Converter as MarkdownToHtmlConverter } from '@memochou1993/markdown2html';

const markdown = JsonToMarkdownConverter.toMarkdown({
  status: '😤',
});

const html = MarkdownToHtmlConverter.toHTML(markdown);

console.log(html);

// Output:
// <h1>status</h1>
// <p>😤</p>

Markdown Image

Logo

HTML Link

Visit GitHub

License

MIT

About

A web demo for converting JSON to Markdown

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published