gchq/CyberChef · error · OperationError

Error: Invalid output format

Error message

Error: Invalid output format

What it means

Thrown by the RegularExpression operation when the 'output format' argument does not match any of the supported cases (Highlight matches / List matches / List capture groups / List matches with capture groups). In normal UI use this is unreachable because the value comes from a dropdown, but programmatic or hand-edited recipes can hit the default branch.

Source

Thrown at src/core/operations/RegularExpression.mjs:171

        if (s) modifiers += "s";
        if (u) modifiers += "u";
        if (a) modifiers += "A";

        if (userRegex && userRegex !== "^" && userRegex !== "$") {
            try {
                const regex = new XRegExp(userRegex, modifiers);

                switch (outputFormat) {
                    case "Highlight matches":
                        return regexHighlight(input, regex, displayTotal);
                    case "List matches":
                        return Utils.escapeHtml(regexList(input, regex, displayTotal, true, false));
                    case "List capture groups":
                        return Utils.escapeHtml(regexList(input, regex, displayTotal, false, true));
                    case "List matches with capture groups":
                        return Utils.escapeHtml(regexList(input, regex, displayTotal, true, true));
                    default:
                        throw new OperationError("Error: Invalid output format");
                }
            } catch (err) {
                throw new OperationError("Invalid regex. Details: " + err.message);
            }
        } else {
            return Utils.escapeHtml(input);
        }
    }

}

/**
 * Creates a string listing the matches within a string.
 *
 * @param {string} input
 * @param {RegExp} regex
 * @param {boolean} displayTotal
 * @param {boolean} matches - Display full match

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Use one of the exact supported outputFormat strings: 'Highlight matches', 'List matches', 'List capture groups', 'List matches with capture groups'.
  2. If scripting, validate outputFormat against an allow-list before invoking.
  3. Re-export the recipe from a current CyberChef build to refresh option names.

Example fix

// before
//   outputFormat: "highlight"
// after
//   outputFormat: "Highlight matches"
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = ['Highlight matches','List matches','List capture groups','List matches with capture groups']; if (!ALLOWED.includes(outputFormat)) throw new Error('Unsupported output format');

Type guard

const isOutputFormat = v => ['Highlight matches','List matches','List capture groups','List matches with capture groups'].includes(v);

Try / catch

try { runRegex(input, { outputFormat }); } catch (e) { if (/Invalid output format/.test(e.message)) outputFormat='Highlight matches'; else throw e; }

Prevention

When it happens

Trigger: Programmatically building a recipe with a typo'd or unsupported outputFormat string; loading a recipe exported from an incompatible CyberChef version where the option name changed; an outdated config.

Common situations: Scripting recipes via the Node API with an invalid outputFormat; migrating recipes between CyberChef versions; locale/casing differences in the option string.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/1cd42e2dce290f31. Report an issue: GitHub.