Skip to main content

Try it Live

Run Bytecode examples in the interactive playground

    Output Format

    Options

    Usage Patterns

    Basic Disassembly

    Gas-Focused View

    Stack-Focused View

    Compact Mode

    Save to File

    Disable colors when saving to file to avoid ANSI escape sequences in text files.

    Color Coding

    Instructions are color-coded by category:
    Color scheme optimized for dark terminals. Colors automatically disabled if stdout is not a TTY.

    Block Visualization

    Basic blocks shown with metadata header:
    Block Header Format:
    • gas: N - Total gas for block (sequential execution)
    • stack: [min, max] - Min required, max reached
    • len: N - Instruction count
    Block Markers:
    • ● Begin - Marks JUMPDEST blocks (entry points)
    • Blank line separates blocks visually

    Jump Visualization

    Jump instructions show arrows connecting to targets:
    Jump Symbols:
    • ┐→N - Forward jump (down in code) to PC N
    • ┘→N - Backward jump (up in code) to PC N
    • ←● - Jump target (valid JUMPDEST)
    • ←✗ - Invalid jump target (not JUMPDEST) - highlights bugs!
    • →? - Jump target unknown or outside bytecode
    Pretty print highlights jumps to non-JUMPDEST locations with red marker. This indicates malformed bytecode that will revert at runtime.

    Fusion Annotations

    Detected fusion patterns annotated inline:
    Fusion Markers:
    • prefix on hex column - Fusion opportunity
    • ⚡ PUSH+ADD suffix - Pattern type
    • Green background for fusion marker
    See Fusion Detection for all 20+ patterns.

    Inline Metadata

    PUSH Values

    Shows both hex (0x42) and decimal (66) for values ≤ 0xFFFF.

    Gas Costs

    Base gas cost from Opcode.getGasCost().

    Stack Effects

    Shows inputs consumed (-2) and outputs produced (+1).

    Jump Targets

    Shows this is a valid jump destination at PC 50.

    Summary Section

    Footer shows aggregate statistics:
    Warnings:
    • ⚠️ Invalid jumps - Jumps to non-JUMPDEST (red, critical)
    • ⚠️ Final stack depth - Non-zero final depth (yellow, warning)
    • ❌ Stack underflow - Popping from empty stack (red, critical)

    Comparison with formatInstructions

    Use prettyPrint() for:
    • Debugging and visualization
    • Terminal output
    • Understanding control flow
    • Gas analysis
    • Educational purposes
    Use formatInstructions() for:
    • Programmatic parsing
    • Simple disassembly
    • Integration with other tools
    • Machine-readable output

    Advanced Usage

    Debug Specific Range

    Compare Bytecode Versions

    Extract Function Bodies

    Integration with Logger

    Terminal Compatibility

    Color Support Detection

    Width Detection

    Unicode Fallback

    If terminal doesn’t support Unicode box-drawing characters:

    Performance

    Pretty printing is optimized for readability over speed:
    • Small bytecode (<1KB): <5ms
    • Medium bytecode (10KB): ~50ms
    • Large bytecode (24KB): ~120ms
    Use formatInstructions() if performance is critical and visual output not needed.
    TypeScript-only: Pretty printing requires complex string formatting with ANSI colors and Unicode drawing. Use simpler APIs like Scanner in Zig for bytecode iteration.

    See Also