Issue #6038πŸ’¬ AnsweredOpened Aug 6, 2024by dharma-glui0 reactions

Inline event declarations like onclick event on a buttons are getting removed

Quick answerby artf

This is intentional for security reasons, but you can disable it with the option config.parser.optionsHtml.allowUnsafeAttr (at your own risk): https://github.com/GrapesJS/grapesjs/blob/819bfcf44bb23d51990eba3b4330e9932df59cde/src/parser/config/config.ts#L116

Read full answer below ↓

Question

GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? ChromeReproducible demo link https://jsfiddle.net/6bn43a05/Describe the bug How to reproduce the bug?Add a onclick event for a html tag What is the expected behavior? It should not remove the event after getting loaded in to the editor What is the current behavior? It removes the onclick event from html If is necessary to execute some code in order to reproduce the bug, paste it here below: Same issue reported here : https://stackoverflow.com/questions/78496572/grapesjs-removes-onclick-attributes-ho...

Answers (2)

GJS Helperβ€’ May 17, 2026

The issue you're encountering, where onclick attributes are removed from HTML elements when loaded into GrapesJS, is a deliberate security feature and part of GrapesJS's HTML sanitization process. GrapesJS, like many modern HTML editors, strips potentially unsafe attributes and tags to prevent Cros...

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

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.

All tutorials β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.