Convert & to & < to $lt; and save html data
Question
Im using editor and generating a html string and saving it to a file. But before saving I have to encode all the &, <, > characters.
Please Help
Answers (2)
@suchiitsme
editor.on('storage:start:store', o => {
o.html = o.html.replace(/&/gi,'&')
o.html = o.html.replace(/</gi,'<')
o.html = o.html.replace(/>/gi,'>')
})
cheers!
In the next release, we'll escape HTML characters https://github.com/artf/grapesjs/pull/2446
Related Questions and Answers
Continue research with similar issue discussions.
Issue #605
How we can save HTML
How we can save HTML without using editor.getHtml() and replace function. As, when we are using this in image upload then the existing vide...
Issue #778
save to db data-gjs-droppable
Hi guys, I need to solve a problem. Saving html grapejs strip all data-gjs- from html. Exists a way to maintain all data-gjs- before save e...
Issue #1993
[QUESTIONS] is any way to store the html id with its component when i click save button
Hi. I know the grapesjs will generate the unique id for each HTML. when I store that HTML and CSS. the HTML id is not stored in my database...
Issue #911
Could some one please help me with Custom Load.
What I can use instead of followings- editor.setHtml( arrdata['html'] ), editor.setCss( arrdata['css'] ), In below code.
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Related tutorials
In-depth guides on the same topic.
Tutorial
🚀 Big Update: Import, Edit & Export Documents with Ease + 14-Day Pro Trial
We’ve just shipped a major update to gjsdocs.com — and it changes how you work with documents
Tutorial
Super Tooltip for GrapesJS — Version 0.1.5 Released 🎉
We’re excited to announce the v 0.1.5 update of Super Tooltip, our floating‑menu and tooltip plugin for GrapesJS
Tutorial
Best GrapesJS Plugins in 2025 (Updated List)
Discover the top free and premium GrapesJS plugins in 2025 — boost your editor with UI kits, Tailwind blocks, AI tools, and advanced page managers.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.