By · Updated

Minecraft dialogs: build a dialog GUI on 1.21.6+ and Paper

5commands
2files
6min read
Sheet 12 of 20 · server owners

Filesdata/myserver/dialog/rules.json · data/myserver/dialog/report.json

Filedata/myserver/dialog/rules.jsonFiledata/myserver/dialog/report.jsonCommand/dialog showCommand/dialog show @s myserver:rulesA dialog is a native Minecraft screen, added in Java Edition 1.21.6, with a title, body text, input fields and buttons. It is not a chest menu: players get real text boxes, tick boxes, option lists and sliders, and the buttons run a command or send the answers back to the server. You can define one in a data pack and open it with /dialog show, or build it in code with Paper's dialog API, which arrived in Paper 1.21.7. To see one before you write any of that, draw it in GUI Studio and export the JSON.

Dialogs or chest GUIs

Most server menus are still chest inventories with items in slots, and for a grid of things to click (a shop, a warp list, a kit picker) that is still the right tool. Dialogs are better at the other half of the job:

Chest GUIDialog
Typed inputAnvil tricks or chat promptsA real text field, up to max_length characters
Numbers and togglesOne item per valueA slider and a tick box
Layout9 columns, items onlyText, items, inputs and a row of buttons
Minecraft versionAny1.21.6 and newer clients
Bedrock through GeyserChest formsBedrock forms, since Geyser 2.8.0

Settings, confirmations, reports, rename prompts and rule screens are where dialogs earn their place. A client older than 1.21.6 has no dialog screen at all, so if ViaVersion lets older clients in, keep a fallback. Inventory GUI vs dialog vs cursor menu compares them in more detail and adds cursor menus.

The five dialog types

TypeWhat it showsFooter
minecraft:noticeA message with one buttonThat button, which is also what Esc does
minecraft:confirmationA yes or no questionyes and no, both required
minecraft:multi_actionA scrollable set of buttons, in columns (2 by default)Only an exit_action if you set one
minecraft:server_linksThe links the server sends in its server links listexit_action
minecraft:dialog_listButtons that open other dialogsexit_action

Every type takes the same base fields: title (required), external_title, body, inputs, can_close_with_escape (default true), pause (default true, and it only pauses in singleplayer) and after_action (close, none or wait_for_response).

The body is one element or a list of them: minecraft:plain_message for text and minecraft:item to show an item with its tooltip.

Inputs

InputKey fieldsWhat the player gets
minecraft:textmax_length (32), initial, multilineA text box
minecraft:booleaninitial, on_true, on_falseA tick box
minecraft:single_optionoptions with id, display, initialA button that cycles through options
minecraft:number_rangestart, end, step, initialA slider

Every input has a key and a label. The key may only hold letters, digits and _, because it is used as a template argument.

Button actions

ActionDoes
run_commandRuns command as the player. The leading / is optional
dynamic/run_commandFills template with the inputs, $(key) for each, and runs it
suggest_commandPuts command in the chat box
open_urlOpens url in the browser
copy_to_clipboardCopies value
show_dialogOpens another dialog, by id or inline
custom, dynamic/customSends an id, and for dynamic/custom the inputs, to the server. Vanilla ignores it, plugins read it

A command from a dialog runs with the player's own permissions. A button cannot make a regular player run an op command, so whatever run_command points at has to be a command that player is allowed to use.

A dialog in a data pack

Dialogs live in data/<namespace>/dialog/<name>.json inside a data pack. A rules screen with one button:

data/myserver/dialog/rules.json
{
  "type": "minecraft:notice",
  "title": { "text": "Server rules", "color": "gold", "bold": true },
  "body": [
    { "type": "minecraft:plain_message", "contents": "1. No cheats, x-ray or duping." },
    { "type": "minecraft:plain_message", "contents": "2. Be decent in chat. No slurs, spam or ads." },
    { "type": "minecraft:plain_message", "contents": "3. Do not grief builds you were not invited to." }
  ],
  "action": { "label": "I agree", "width": 150 }
}

A form that collects input and hands it to a command:

data/myserver/dialog/report.json
{
  "type": "minecraft:multi_action",
  "title": "Report a player",
  "inputs": [
    { "type": "minecraft:text", "key": "name", "label": "Player", "max_length": 16 },
    {
      "type": "minecraft:single_option",
      "key": "reason",
      "label": "Reason",
      "options": [
        { "id": "cheating", "display": "Cheating", "initial": true },
        { "id": "chat", "display": "Chat abuse" }
      ]
    }
  ],
  "actions": [
    { "label": "Send", "action": { "type": "dynamic/run_command", "template": "report $(name) $(reason)" } }
  ],
  "exit_action": { "label": "Cancel" }
}

The report command has to exist on your server; the dialog only types it for the player.

Opening dialogs

    1. Load the data pack

      Put the pack in the world's datapacks folder and restart the server. Dialogs are one of the data pack parts that /reload does not pick up, the same as dimensions and damage types.

    2. Show it

      Command/dialog show @s myserver:rulesCommand/dialog show @a myserver:rules/dialog show @s myserver:rules opens it for you, /dialog show @a myserver:rules for everyone. The command needs permission level 2, so it is for ops, the console, command blocks and functions.

    3. Try one without a pack

      Command/dialog show/dialog show also takes an inline dialog in place of the id, which is the quickest way to test a layout. GUI Studio's "/dialog command" export writes exactly that.

    4. Close it from the server

      Command/dialog clear @s/dialog clear @s closes whatever dialog the player has open.

Two tags put dialogs where players find them without a command. Dialogs in #minecraft:pause_screen_additions get a button on the pause menu, and dialogs in #minecraft:quick_actions open with the Quick Actions key, G by default. With several dialogs in one tag the client shows a list to pick from.

Dialogs from a Paper plugin

Paper 1.21.7 added a dialog API, documented on the Paper dialogs page. The simplest dialog there is three lines:

Dialog dialog = Dialog.create(builder -> builder.empty()
    .base(DialogBase.builder(Component.text("Title")).build())
    .type(DialogType.notice()));
 
player.showDialog(dialog);

A confirmation whose button runs code instead of a command uses a click callback. This is the pattern IgniteSky uses for every destructive action:

ActionButton yes = ActionButton.builder(Component.text("Delete", NamedTextColor.RED))
    .action(DialogAction.customClick(
        (view, audience) -> {
            if (audience instanceof Player clicker) {
                clicker.getScheduler().run(plugin, task -> deleteHome(clicker, "base"), null);
            }
        },
        ClickCallback.Options.builder().uses(1).build()))
    .build();
ActionButton no = ActionButton.builder(Component.text("Keep it")).build();
 
Dialog dialog = Dialog.create(builder -> builder.empty()
    .base(DialogBase.builder(Component.text("Delete home \"base\"?"))
        .body(List.of(DialogBody.plainMessage(Component.text("This cannot be undone."))))
        .build())
    .type(DialogType.confirmation(yes, no)));
 
player.showDialog(dialog);

Inputs are added with DialogInput.text, DialogInput.bool, DialogInput.singleOption and DialogInput.numberRange on the base builder, and read back in the callback from the DialogResponseView with getText, getBoolean and getFloat. Dialogs registered by id, and the PlayerCustomClickEvent for custom actions, are covered in Paper's docs.

What we ran into building IgniteSky's dialogs:

  • Esc on a notice presses its button. The notice's one button is also its exit action. For a form with a submit button, use multi_action without an exit_action, so Esc closes it without submitting.
  • Paper checks the initial values. A pre-filled text longer than its maxLength, or a slider initial outside its range, throws when the dialog is built. Clamp them first.
  • Keys are strict. Lower-case the input keys and replace anything outside a-z, 0-9 and _.
  • Folia. Show the dialog and run the callback's work on the player's own scheduler, as above. IgniteSky does both, so its dialogs run on Folia unchanged.
  • One use per click callback. uses(1) stops a double click from running a delete twice.
  • Config keydialogs.enabledKeep a fallback. IgniteSky has a dialogs.enabled switch and falls back to chest menus for settings and confirmations when it is off. Its native dialogs section lists which screens use them.

Draw it first in GUI Studio

Writing dialog JSON by hand and reloading to see the result gets slow fast. GUI Studio is a free editor in the browser that draws dialogs and chest menus with the game's own font and item icons:

  • Start from a preset: a settings dialog with all four input types, a notice and a confirmation whose yes button runs a command.
  • Command/dialog showPaste an existing dialog JSON, or a whole /dialog show command, and it is read back into the editor. server_links and dialog_list dialogs preview their title and body only.
  • Command/dialog showExport as dialog JSON for a data pack, or as a /dialog show command to paste in game.
  • The same tool exports chest menus as DeluxeMenus or IgniteAPI YAML, so one project can hold the dialog and the menu that opens it.

Your work saves in the browser you made it in.

Quick answers

  • Which version added dialogs? Java Edition 1.21.6. Paper's Java API for them came in 1.21.7.
  • Can players open them without op? Not with /dialog, it needs level 2. Give them a plugin command, the pause menu tag or the Quick Actions key.
  • Do Bedrock players see them? Through Geyser, yes, as Bedrock forms.
  • Can a dialog show a chest grid? No. Use a chest GUI for grids and open a dialog from one of its buttons for the input part.

Where to go next

Written from

  1. Minecraft Wiki: Dialog
  2. Minecraft Wiki: /dialog command
  3. Minecraft Wiki: Java Edition 1.21.6
  4. Minecraft Wiki: Data pack (dialogs need a restart)
  5. Paper docs: dialogs
  6. Geyser 2.8.0 changelog: dialog translation