# Swap endianness

Switches the data from big-endian to little-endian or vice-versa. Data can be read in as hexadecimal or raw bytes. It will be returned in the same format as it is entered. Swap endianness lives in the **Data format** category of the `fx` menu.

## Parameters

| Parameter            | Type    | Required | Default | Description                                            |
| -------------------- | ------- | -------- | ------- | ------------------------------------------------------ |
| Input                | string  | yes      | —       | Value to transform. Previous step output or a literal. |
| Data format          | string  | no       | `Hex`   | Choose one of: `Hex`, `Raw`.                           |
| Word length (bytes)  | number  | no       | `4`     | Numeric value. Default `4`.                            |
| Pad incomplete words | boolean | no       | `true`  | Enabled by default.                                    |

`Input` is the primary value (previous step output or a literal).

## Returned value

| Type     | Description                                   |
| -------- | --------------------------------------------- |
| `string` | Result of the Swap endianness transformation. |

## Limitations

- Invalid or mismatched encoding for the chosen options typically raises an evaluation error — fix the Input or options before re-running.

## Example

<details>
<summary>Run Swap endianness</summary>

Switches the data from big-endian to little-endian or vice-versa. Adjust optional parameters when the defaults do not match your payload.

1. Set **Input** to the value to transform (previous step output or a literal).

2. Review **Data format**, **Word length (bytes)**, **Pad incomplete words** and keep defaults unless your format requires otherwise.

3. Confirm **Output value** shows the transformed result.

</details>
