> For the complete documentation index, see [llms.txt](https://docs.hex-rays.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hex-rays.com/ida-9.5/core/user-interface/how-tos/exporting-and-copying-listings.md).

# Exporting and copying listings

Every [listing](/ida-9.5/core/user-interface/concepts/subviews.md#listings) — the flat disassembly, the hex view, the decompiler's pseudocode and microcode, and the type listing — can be copied to the clipboard or exported to an HTML file. Both operations share the same idea: you point at what you want (or select it), and IDA renders it faithfully, in your current colors.

This page covers the two flows:

* [Copying to the clipboard](#copying-to-the-clipboard): the **Copy** submenu of every listing's context menu, and <kbd>Ctrl</kbd>+<kbd>C</kbd>.
* [Exporting to an HTML file](#exporting-to-an-html-file): **File → Produce file → Export to HTML...**, template-driven, up to the whole database.

## What gets copied or exported

The scope is decided the same way everywhere, in this order:

1. **The selection**, if there is one. Selections are column-precise: the copy starts and ends exactly where the painted selection does: the first line from the selection's start column, the last line up to its end column (a selection ending before a line's first glyph contributes nothing of that line).
2. **The highlighted identifier**, if any: click a name to highlight it, and a copy takes just that word.
3. Otherwise, **the item under the cursor**: the whole function in a disassembly or pseudocode listing (including its [tail chunks](https://hex-rays.com/blog/igors-tip-of-the-week-86-function-chunks), wherever in the address space they live), the whole type in a type listing, or the current item elsewhere.

When you want whole lines rather than column precision, hold <kbd>Ctrl</kbd> *before starting* the mouse selection: this enters **full-lines mode**, where every line the selection touches is selected in full: painted, copied and exported as whole lines. (On macOS this is the <kbd>⌃ Control</kbd> key, not <kbd>⌘ Command</kbd>.) Here is the same drag, without and with <kbd>Ctrl</kbd>:

![A regular selection is column-precise: it starts and ends exactly where you drag](https://492083732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFP6ibt8r6WPBHTqekG9u%2Fuploads%2Fgit-blob-39b32121a4cfd586a949c00f82051ed8230202c0%2Fselection-regular.png?alt=media)

![The same drag started with Ctrl held selects full lines](https://492083732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFP6ibt8r6WPBHTqekG9u%2Fuploads%2Fgit-blob-27e0efe7483e53f5d612cdca14505a1259e4a0b0%2Fselection-full-lines.png?alt=media)

You never have to guess: the submenu's caption names what a copy will grab: **Copy selection**, **Copy highlight**, **Copy function**, **Copy type**, or **Copy item**.

## Copying to the clipboard

Right-click any listing: the **Copy ...** submenu is the first entry. It offers the flavors that apply to that listing:

* [**As text**](/ida-9.5/ida-actions/copylistingastext.md): plain text, exactly as the listing shows it. This is the plain copy, bound to <kbd>Ctrl</kbd>+<kbd>C</kbd> (or your platform's Copy key).

![The As text flavor in the Copy submenu](https://492083732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFP6ibt8r6WPBHTqekG9u%2Fuploads%2Fgit-blob-1f96e68310b240295248ec1f3a6fb98d5a14ad2c%2Fcopy-as-plain.png?alt=media)

For example, with the cursor inside `main` of a small program, **As text** puts the whole function on the clipboard:

```
.text:08048492
.text:08048492 ; =============== S U B R O U T I N E =======================================
.text:08048492
.text:08048492 ; Attributes: bp-based frame
.text:08048492
.text:08048492 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:08048492                 public main
.text:08048492 main            proc near               ; DATA XREF: _start+17↑o
.text:08048492
.text:08048492 char_in_main    = byte ptr -5
.text:08048492 foo             = dword ptr -4
.text:08048492 argc            = dword ptr  8
.text:08048492 argv            = dword ptr  0Ch
.text:08048492 envp            = dword ptr  10h
.text:08048492
.text:08048492 ; __unwind { // .__gxx_personality_v0
.text:08048492                 push    ebp
.text:08048493                 mov     ebp, esp
.text:08048495                 sub     esp, 18h
.text:08048498                 mov     [ebp+char_in_main], 62h ; 'b'
.text:0804849C                 lea     eax, [ebp+char_in_main]
.text:0804849F                 mov     [esp+4], eax    ; in_char_ptr
.text:080484A3                 mov     dword ptr [esp], 7Ah ; 'z' ; in_char
.text:080484AA                 call    return_int(char,char *)
.text:080484AF                 mov     [ebp+foo], eax
.text:080484B2                 mov     eax, [ebp+foo]
.text:080484B5                 leave
.text:080484B6                 retn
.text:080484B6 ; } // starts at 8048492
.text:080484B6 main            endp
.text:080484B6
.text:080484B6 ; ---------------------------------------------------------------------------
```

* [**As HTML**](/ida-9.5/ida-actions/copylistingashtml.md): the same text carrying the listing's syntax colors, so it pastes styled into rich-text editors, chats and documents. The HTML source is also placed on the plain-text clipboard flavor, so pasting into a plain-text editor yields the markup itself, ready to embed.

![The As HTML flavor in the Copy submenu](https://492083732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFP6ibt8r6WPBHTqekG9u%2Fuploads%2Fgit-blob-e07aa63c1b7f97aa9ea7808319275bbd36c90438%2Fcopy-as-html.png?alt=media)

Here is the same `main`, copied **As HTML**. A whole function's markup is a wall of `<span>`s, so this sample is a selection of its first fifteen lines: the function header in full, stopping just short of the first instruction.

```html
<pre style="white-space: pre; color: blue; background-color: white;">
<span style="color: #000000;">.text:08048492</span>
<span style="color: #000000;">.text:08048492</span> <span style="color: #808080;">; =============== S U B R O U T I N E =======================================</span>
<span style="color: #000000;">.text:08048492</span>
<span style="color: #000000;">.text:08048492</span> <span style="color: #808080;">; Attributes: bp-based frame</span>
<span style="color: #000000;">.text:08048492</span>
<span style="color: #000000;">.text:08048492</span> <span style="color: #0000ff;">; int __cdecl main(int argc, const char **argv, const char **envp)</span>
<span style="color: #000000;">.text:08048492</span>                 <span style="color: #0000ff;">public </span><span style="color: #0000ff;">main</span>
<span style="color: #000000;">.text:08048492</span> <span style="color: #0000ff;">main</span><span style="color: #0000ff;">            proc near</span>               <span style="color: #8080ff;">; DATA XREF: _start+17↑o</span>
<span style="color: #000000;">.text:08048492</span>
<span style="color: #000000;">.text:08048492</span> <span style="color: #008000;">char_in_main</span>    <span style="color: #000080;">=</span> <span style="color: #000080;">byte</span> <span style="color: #000080;">ptr</span> <span style="color: #008040;">-5</span>
<span style="color: #000000;">.text:08048492</span> <span style="color: #008000;">foo</span>             <span style="color: #000080;">=</span> <span style="color: #000080;">dword</span> <span style="color: #000080;">ptr</span> <span style="color: #008040;">-4</span>
<span style="color: #000000;">.text:08048492</span> <span style="color: #008000;">argc</span>            <span style="color: #000080;">=</span> <span style="color: #000080;">dword</span> <span style="color: #000080;">ptr</span> <span style="color: #008040;"> 8</span>
<span style="color: #000000;">.text:08048492</span> <span style="color: #008000;">argv</span>            <span style="color: #000080;">=</span> <span style="color: #000080;">dword</span> <span style="color: #000080;">ptr</span> <span style="color: #008040;"> 0Ch</span>
<span style="color: #000000;">.text:08048492</span> <span style="color: #008000;">envp</span>            <span style="color: #000080;">=</span> <span style="color: #000080;">dword</span> <span style="color: #000080;">ptr</span> <span style="color: #008040;"> 10h</span>
<span style="color: #000000;">.text:08048492</span></pre>
```

{% hint style="info" %}
Every HTML flavor (the clipboard's, and the exported files' below) inlines the colors of your *current* IDA color theme, read live from the view. Switch theme, and the next copy or export follows it; nothing hard-codes a fixed palette.
{% endhint %}

* **As deeplink**: an `ida://` URL to the current location, for sharing an exact spot in the database with your team. See [Using Deep Links](/ida-9.5/core/user-interface/how-tos/using-deep-links.md).

![The As deeplink flavor in the Copy submenu](https://492083732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFP6ibt8r6WPBHTqekG9u%2Fuploads%2Fgit-blob-2ece51dd27586c0452b4ee6124e8c0239f1792b9%2Fcopy-as-deeplink.png?alt=media)

* **Copy with dependencies**: in type listings only: the C-style declarations of the type(s), together with every type they depend on, so the result compiles on its own.

![Copy with dependencies on a type listing](https://492083732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFP6ibt8r6WPBHTqekG9u%2Fuploads%2Fgit-blob-efad5b3c74c3ee677cda6179f4284a96f5379c18%2Fcopy-with-dependencies.png?alt=media)

In the **Local Types** side tree, the same submenu appears as **Copy type** (or **Copy types**, following your selection), offering the deeplink and with-dependencies flavors for the selected types. The plain <kbd>Ctrl</kbd>+<kbd>C</kbd> in the tree copies the item names, as in every tree.

![The Copy types submenu in the Local Types side tree](https://492083732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFP6ibt8r6WPBHTqekG9u%2Fuploads%2Fgit-blob-3b7b11885191d89785955e0617117cf8ee54e3b8%2Fcopy-types-side-tree.png?alt=media)

Every copy is confirmed in the *Output* window ("Copied ... to clipboard").

{% hint style="info" %}
In the hex view, copies currently cover whole lines; a block (column) selection is copied with its full lines.
{% endhint %}

## Exporting to an HTML file

Choose **File → Produce file → Export to HTML...** (the label follows the context: *Export selection to HTML...*, *Export "IDA View-A" to HTML...*). With an active selection, the action is also offered at the end of the listing's context menu.

![The Export to HTML dialog](https://492083732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFP6ibt8r6WPBHTqekG9u%2Fuploads%2Fgit-blob-d589808aee1a394d0363d01aea4ea93170fb7fbc%2Fexport-html-dialog.png?alt=media)

The dialog offers:

* **Output file**: where the page is written. The suggested name follows the export scope: the subject's name for a current-function/type export, the input file's name for a whole-listing one.
* **Template**: how the page is rendered (see [the templates](#the-templates) below). The frame underneath describes the selected template; its tooltip shows the template file that will run.
* **Export**: what to export: the **current function/type** under the cursor, or the **entire listing**. These radios appear only when there is no selection; a selection *is* the scope, and is exported as-is.
* **Expand collapsed functions**, for disassembly exports: collapsed functions and hidden ranges are rendered in full (the view's fold state is restored afterwards).
* **Open in browser**: open the result when done.

The template choice and the options are remembered across sessions. Generation shows a progress dialog and can be cancelled at any point; a cancelled export leaves no partial file behind.

### The templates

Three templates ship with IDA:

* **Plain static export**: a standalone HTML page of the listing, with IDA's colors, and no interactivity.

![A plain static export rendered in a browser](https://492083732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFP6ibt8r6WPBHTqekG9u%2Fuploads%2Fgit-blob-c78b3bad1f33c89c16be0ba273161bfaef9ecf91%2Fexport-html-static.png?alt=media)

* **Interactive with sidebar**: a standalone page featuring a sidebar listing the exported functions, a live jump-arrow gutter, in-document links for names and cross-references (offset-aware, pseudocode call targets included), and toggles for prefixes, cross-references, comments and arrows.

![An interactive export rendered in a browser](https://492083732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFP6ibt8r6WPBHTqekG9u%2Fuploads%2Fgit-blob-d7851950e16a35b70f07bd83919ac9f5a6161a0b%2Fexport-html-interactive.png?alt=media)

* **Snippet**: a paste-ready HTML fragment: an inline-styled block with per-span colors and no stylesheet, to drop into a document.

The templates are IDAPython scripts, shipped with the IDAPython examples and installed under `idadir/python/examples/templates` — the `README.md` there documents the contract. Picking **Custom...** in the template combo lets you run your own: any `.py` file exposing a `title`, a `description`, and a `run()` entry point. The shipped templates are the reference to start from.

{% hint style="info" %}
Without IDAPython, the export falls back to a built-in generator producing a plain static page; the template picker is not shown.
{% endhint %}

### Scripting the export

The engine behind both flows is scriptable. From IDAPython:

```python
import ida_lines

cfg = ida_lines.export_listing_t()
cfg.add_function(here())          # or cfg.add_whole_disassembly()
cfg.title = "my function"
errbuf, nlines = ida_lines.export_listing_to_file("out.html", cfg)
```

A complete headless example (exporting a database's listing without opening the UI) ships as the `export_listing.py` example of [idalib](/ida-9.5/core/idalib.md).

## See also

* [Using Deep Links](/ida-9.5/core/user-interface/how-tos/using-deep-links.md): sharing and following `ida://` links.
* [Working with types](/ida-9.5/core/types/how-tos/working-with-types.md): the type listing and Local Types view.
* The **File → Produce file** menu: the other output formats (ASM, LST, MAP, ...).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.hex-rays.com/ida-9.5/core/user-interface/how-tos/exporting-and-copying-listings.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
