I have a json doc, what should I do to convert it into plain text?

Hi all,

I have a prosemirror json document:

  type: 'doc',
  content: [
    { type: 'paragraph', content: [ { type: 'text', text: 'Ciao ' } ] },
    { type: 'paragraph' },
      type: 'paragraph',
      content: [
          type: 'text',
          marks: [ { type: 'strong' } ],
          text: 'I am bold'

My goal is to convert it to plain text, assuming I’m not running a browser.

What are the steps I need? Do I need to write a custom parser/serializer?


1 Like

There is no single canonical way to convert a rich text document to plain text. You maybe want to use Node.textBetween or MarkdownSerializer.