Skip to main content

HTML Dialog Generator

API reference

Generate a native HTML <dialog> modal or popup — set the title, text, open and close buttons, modal or non-modal mode, and light-dismiss behavior, then copy accessible, JavaScript-free markup with a live preview.

Input

Settings

Sets the closedby attribute. Older browsers ignore it and fall back to the default (Esc closes a modal).

Letters, digits, - and _ only.

Adds a small script that opens the dialog in browsers without HTML invoker commands support (pre-2025 versions).

Add custom CSS classes to the element. Separate multiple classes with spaces.

Output

Your element will appear here.

HTML
 
Was this helpful?

More ways to use this tool

REST API

curl -X POST https://api.iotools.cloud/v1/tool/html-generator/dialog \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "customTitle": "Hello there!",
    "customContent": "This is a native dialog.",
    "customOpenText": "Open dialog",
    "customCloseText": "Close",
    "customMode": "modal",
    "customClosedBy": "",
    "customId": "my-dialog",
    "customFallback": "",
    "customClasses": ""
  }'

Swap in your own key from your account. The tool's fields are the body — no wrapper.

Ask an AI agent

Use the IOTools `html-generator__dialog` tool (HTML Dialog Generator) on this input:

YOUR_INPUT_HERE

Paste this at any agent connected to the IOTools MCP server, then add your input.

Embed widget

<iframe
  src="https://iotools.cloud/embed/html-generator/dialog/"
  width="100%" height="520" frameborder="0" scrolling="no" loading="lazy"
  title="HTML Dialog Generator — iotools.cloud"
  sandbox="allow-scripts allow-forms allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox"
  allow="clipboard-write"
  style="width:100%;border:1px solid #e5e7eb;border-radius:12px;overflow:hidden"></iframe>
<script src="https://iotools.cloud/embed.js" async></script>

Drop this into your own page — free, no key required, just a link back.

Cost per API/MCP callFrom 5 credits
Need more credits?View pricing

Also available with

Guides

Generate a native HTML <dialog> — a modal or popup window built into the browser, with focus handling, the Esc key and a backdrop for free. Set the title, the text and the button labels, pick modal or non-modal, and copy markup that works without a single line of JavaScript.

Runs entirely in your browser: no AI call, no credits, no network round-trip. The output and the live preview update as you type — click the open button in the preview to try the real dialog.

How to use it

  1. Enter the dialog's Title and Content, plus labels for the Open Button and Close Button.
  2. Choose a Mode:
    • Modal — opens on top of everything with a dimmed backdrop; the rest of the page can't be clicked until it closes.
    • Non-modal — opens in place while the page stays interactive, useful for toolbars or chat popups.
    • Always open — an inline dialog with the open attribute and no open button, e.g. a notice the visitor dismisses.
  3. Under Close On, decide how it can be dismissed: the browser default, light dismiss (Esc or a click outside), Esc only, or the close button only.
  4. Copy or download the HTML.

How it works without JavaScript

The open button uses HTML invoker commands — commandfor="my-dialog" command="show-modal" — which tell the browser to open the dialog directly. They are supported in current Chrome, Edge, Firefox and Safari. The close button sits inside a <form method="dialog">, which closes the dialog in every browser that supports <dialog>.

Need to support older browsers? Tick Add JavaScript fallback to append a short script. It only runs where invoker commands are missing and calls showModal() (or show()) for you.

Is the generated dialog accessible?

Yes. A native <dialog> already gets the dialog role, moves focus inside when it opens, and returns focus to the button when it closes. When you give it a title, the generator links the heading to the dialog with aria-labelledby so screen readers announce it.

How do I style the backdrop?

Use the ::backdrop pseudo-element, e.g. dialog::backdrop { background: rgb(0 0 0 / 0.5); }. Add your own class in CSS Classes to target one dialog. For an expanding section that stays in the page flow instead of a popup, try the HTML Details Generator.

htmldialogmodalpopupshowModalinvoker commandsgenerator

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.