Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including mdast-util-to-string with all npm packages installed. Try it out:

var mdastUtilToString = require("mdast-util-to-string")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

mdast-util-to-string v1.1.0

mdast utility to get the plain text content of a node


Build Coverage Downloads Size Sponsors Backers Chat

mdast utility to get the plain text content of a node.



npm install mdast-util-to-string


var unified = require('unified')
var parse = require('remark-parse')
var toString = require('mdast-util-to-string')

var tree = unified()
  .parse('Some _emphasis_, **importance**, and `code`.')

console.log(toString(tree)) // => 'Some emphasis, importance, and code.'



Get the text content of a node.

The algorithm checks value of node, then alt, and finally title. If no value is found, the algorithm checks the children of node and joins them (without spaces or newlines). If the given node is in fact a list of nodes, serializes them.

This is not a markdown to plain-text library. Use strip-markdown for that.


Use of mdast-util-to-string does not involve hast, user content, or change the tree, so there are no openings for cross-site scripting (XSS) attacks.



See in syntax-tree/.github for ways to get started. See for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.


MIT © Titus Wormer


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free