{"id":41259,"library":"html2slack","title":"html2slack","description":"A Node.js library (v1.9.1) that converts a subset of HTML to JSON formatted Slack attachments using html-minifier and fast-html-parser. It supports bold, italic, strikethrough, inline and multi-line code, quotes, links, ordered/unordered lists, and basic tables. The HTML must contain a <body> with <section> elements. Slack mrkdwn formatting is applied automatically. Release cadence is low, no major changes in recent history. Differentiator: allows reusing HTML templating for Slack bot messages.","status":"active","version":"1.9.1","language":"javascript","source_language":"en","source_url":"https://github.com/aidojs/html2slack","tags":["javascript"],"install":[{"cmd":"npm install html2slack","lang":"bash","label":"npm"},{"cmd":"yarn add html2slack","lang":"bash","label":"yarn"},{"cmd":"pnpm add html2slack","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used to minify and parse HTML input","package":"html-minifier","optional":false},{"reason":"Used to build a DOM tree from HTML","package":"fast-html-parser","optional":false}],"imports":[{"note":"Library ships CommonJS, but default import works in ESM environments.","wrong":"const html2slack = require('html2slack')","symbol":"default","correct":"import html2slack from 'html2slack'"},{"note":"Standard CommonJS require for Node < 14 or CJS projects.","wrong":"","symbol":"html2slack (CommonJS)","correct":"const html2slack = require('html2slack')"},{"note":"Library does not ship TypeScript types; use a .d.ts or @types package if needed.","wrong":"import * as html2slack from 'html2slack'","symbol":"TypeScript types","correct":"import html2slack from 'html2slack'"}],"quickstart":{"code":"const html2slack = require('html2slack');\nconst html = `<body>\n  <section>\n    <p>Hello <b>world</b>!</p>\n  </section>\n</body>`;\nconst slack = html2slack(html);\nconsole.log(JSON.stringify(slack, null, 2));","lang":"javascript","description":"Demonstrates basic usage: converts an HTML snippet with a <body> containing a <section> to a Slack attachment JSON object."},"warnings":[{"fix":"Wrap your content in <body><section>...</section></body>.","message":"HTML must have a <body> tag containing one or more <section> tags. Omitting these will cause parsing errors or empty output.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use <pre> or <textarea> tags specifically for whitespace-sensitive content.","message":"The library uses html-minifier which may strip or modify whitespace, affecting <pre> and <textarea> content.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Update to Node >= 8.0.0 or use an older version of the library.","message":"Support for Node < 8.0.0 is dropped in v1.0.0.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Use only <td> within tables, avoid <th>.","message":"The <table> tag support is experimental and <th> may cause unexpected side effects.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'allow':68 'appli':55 'attach':16 'automat':56 'basic':42 'bold':28 'bot':74 'cadenc':58 'chang':63 'code':36 'contain':47 'convert':7 'differenti':67 'element':50 'fast':23 'fast-html-pars':22 'format':14,53 'histori':66 'html':11,19,24,45,70 'html-minifi':18 'html2slack':1 'inlin':31 'ital':29 'javascript':76 'json':13 'librari':4 'line':35 'link':38 'list':40 'low':60 'major':62 'messag':75 'minifi':20 'mrkdwn':52 'multi':34 'multi-lin':33 'must':46 'node.js':3 'ordered/unordered':39 'parser':25 'quot':37 'recent':65 'releas':57 'reus':69 'slack':15,51,73 'strikethrough':30 'subset':9 'support':27 'tabl':43 'templat':71 'use':17 'v1.9.1':5","created_at":"2026-06-04T18:51:32.226006+00:00","updated_at":"2026-06-04T18:51:32.226006+00:00","problems":[{"fix":"Use import html2slack from 'html2slack' or const html2slack = require('html2slack')","cause":"Using named import instead of default import in ESM or missing require/import.","error":"html2slack is not a function"},{"fix":"Do not JSON.parse the result; html2slack returns a JavaScript object.","cause":"Trying to parse the output as JSON when html2slack returns an object already.","error":"Unexpected token < in JSON at position 0"},{"fix":"Ensure your HTML has a <body> with <section> inside.","cause":"The HTML input lacks a <body> or <section> tag.","error":"Cannot read property 'map' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/aidojs/html2slack#readme","github":"https://github.com/aidojs/html2slack","docs":null,"changelog":null,"pypi":null,"npm":"html2slack","openapi_spec":null,"status_page":null,"smithery":null,"categories":["messaging"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}