# Exporting Files

Ghidra provides an Exporter that allows a user to output program information into a file in various formats.

Some of the formats the Exporter supports are:

- ASCII
- Binary
- C/C++
- Ghidra Zip File (.gzf)
- HTML
- Intel Hex
- XML Export Format

## Export Action

> The export action can be invoked from the front-end project window or the CodeBrowser tool.

> ### To export from the front-end project window:

> > #### Steps:

> > - Right-click on the file to export in the tree.
> > - From the popup menu that appears, select the Export... menu item.
> > - Use the Exporter Dialog that appears to configure the export.
> > - Press the OK button to perform the export.

> ### To export from the CodeBrowser tool:

> > #### Steps:

> > - Make sure the program to export is the currently open program in the CodeBrowser tool.
> > - Invoke the action from the FileExport File... menu item.
> > - Use the Exporter Dialog that appears to configure the export.
> > - Press the OK button to perform the export.

> ## Export Dialog

> > The Export Dialog is used to configure the export of the chosen program.

> > ### Dialog Fields

> > > - Format - This field is a drop-down list containing all the valid export file formats that could be used to to export the program. By default, the last used format will be auto-selected.
> > > - Output File - This field specifies the the output file for the export. By default, the output file's name will be the name of the program and the output folder will be the user's home folder or the last folder used for an export if an export has been performed in the current session. Use the "..." button to bring up a file chooser to change the output file.
> > > - Selection Only - If this checkbox is selected, then only the areas of the program that are in the current selection will be exported. Obviously, this only applies when exporting from an open program with a selection in the CodeBrowser tool and not when exporting from the front-end project window. Also, not all export formats support partial exports. The GZF format, for example, always exports the entire program since it is really just making an exported copy of the entire program database.
> > > - Options... - This button will pop up format specific options for the import.

> ## Exporters

> > ### Ascii

> > > Creates a plain text representation of the program's listing, similar to what is displayed in the Code Browser Field Format.

> > > #### Ascii Options

> > > > #### Advanced

> > > > > Label Suffix | the string to append on the end of labels
> > > > > Comment Prefix | the string to append on the begining of comments

> > > > #### Show

> > > > > The check-boxes in this panel are used to determine what program elements should be included in the output file. A selected check-box denotes that the corresponding element will be included in the file. The checkboxes for elements that are present in the program are selected by default.

> > > > > Comments | Include Pre, Post, EOL, and Plate comments
> > > > > Properties | Include properties; e.g., Bookmarks, Spacers
> > > > > Structures | Include Structures and Unions defined on code units
> > > > > Undefined Data | Include all undefined code units (e.g, "??") or replace with "[BYTES REMOVED]" place-holder
> > > > > Ref Headers | Include the cross reference header BACK[m,n] or FWD[m,n]:, where m is the number of cross references and n is the number of offcut cross reference; select the Back Refs and/or Forward Refs for the Back/FWD header to show up
> > > > > Back Refs | Include the list of cross references for each code unit
> > > > > Forward Refs | Include the list of references to the mnemonic for each code unit
> > > > > Functions | Include signature and header for each function

> > > > #### Width

> > > > > The text-fields in this panel specify the width, in number of characters, to use when displaying program elements in the output file.

> > > > > Setting a width to zero (0) effectively excludes it from the output file.

> > ### Binary

> > > Creates a binary file containing only the bytes from each memory block in the program. If the program was originally created using the Binary Importer, then this exporter allows recreation of the original file.

> > > Only initialized memory blocks are included in the output file.

> > ### C/C++

> > > Create a C/C++ file containing all datatypes from the program's data type manager and all of the functions in the program.

> > > #### C/C++ Options

> > > - Create Header File (.h) - Select to create a .h file.
> > > - Create C File (.c) - Select to create a .c file.
> > > - Use C++ Style Comments (//) - Select to use // or /* style comments.

> > ### Ghidra Zip File (.gzf)

> > > Creates a zip file from a program in your project. You may want to create a zip file so that you can give it to another user who can then import into their project.

> > ### HTML

> > > Creates a hyper-text representation of the program's listing, similar to what is displayed in the Code Browser Field Format. The HTML output is analogous to the ASCII output, however HTML allows format and hyper-link information to be added to the file. The formatting allows fields to be color-matched to those in the Code Browser. The hyper-linking allows navigation similar to that supported in the Code Browser.

> > > The HTML Options are identical the ASCII Options.

> > ### Intel Hex

> > > The Intel Hex format, a printable file representing memory images, was originally designed to program EPROM devices. The Intel Hex exporter creates files in this format which can be used to program these EPROM devices.

> > > #### Intel Hex Options

> > > - Address Space - Specifies which address space to export as Intel Hex format only supports one address space. This option will be intialized to the "default" address space.
> > > - Record Size - Specifies the size (in bytes) of each record in the output file. The default 16.
> > > - Align To Record Size - If checked, this will ensure that only records matching the record size will be output. eg: if you set the record size to 16 but there are 18 bytes selected, you will see only one line of 16 bytes in the output; the remaining 2 bytes will be dropped.

> > ### XML

> > > The XML Exporter creates XML files that conform to Ghidra's Program DTD. You can re-import files in this format using the XML Importer.

> > > The XML Options are identical the XML Importer Options.

> Related Topics:

> - Importing Files