# LibTmux.Workspace\ConvertTo-TmuxWorkspaceYaml

- **Package:** LibTmux.Workspace
- **Language:** PowerShell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/src/LibTmux.Workspace.PowerShell/ConvertToTmuxWorkspaceYamlCommand.cs#L8
- **Page:** https://libtmux.org/en/powershell/latest/workspace/reference/libtmux-workspace-convertto-tmuxworkspaceyaml/

```
ConvertTo-TmuxWorkspaceYaml
    [-Workspace] <LibTmux.Workspace.WorkspaceFile>
    [<CommonParameters>]
```

Convert a native workspace declaration to YAML text.

Return one string for each native WorkspaceFile received from the pipeline.
The text uses the snake_case keys accepted by [`Import-TmuxWorkspace`](/en/powershell/latest/workspace/reference/libtmux-workspace-import-tmuxworkspace/) and the
native parser. Conversion preserves pane and command order, empty strings,
nullable fields, global and local options, post-construction options,
environment and commands at every declaration level. It does not expand
command text or inherit local defaults into children.

Resolved directories and option values contain literal text. Conversion
escapes their dollar signs as `$$` so export, import and a later explicit
[`Resolve-TmuxWorkspace`](/en/powershell/latest/workspace/reference/libtmux-workspace-resolve-tmuxworkspace/) keep the same values. Unresolved variable expressions
remain unchanged.
DocumentDirectory is resolution provenance and is omitted from the text;
provide an explicit base when resolving the imported declaration.

The native parser checks emitted text, including its character limit. This is
not application validation: incomplete declarations can still be converted.
No tmux observation, command execution, file writing or plan serialization
occurs. Formatting and comments from an imported source document are not part
of the native declaration and are not reproduced.

### Notes

Serialization errors terminate with [`Tmux.WorkspaceYamlFailed`](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux.Workspace/ConvertTo-TmuxWorkspaceYaml.md#notes) and retain the
original exception. Null host commands are omitted because the native parser
rejects an explicit null before_script. Nullable name and directory values
remain distinct from empty strings. The native model does not retain a
distinction between omitted and empty collections or omitted and false focus.

## Command details

- **Command type:** [`cmdlet`](/en/powershell/latest/workspace/reference/glossary/#cmdlet)
- **Positional binding:** Enabled.
- **Pipeline inputs:** `LibTmux.Workspace.WorkspaceFile`: A parsed or explicitly resolved declaration.
- **Outputs:** `System.String`

Related APIs:

- [`Import-TmuxWorkspace`](/en/powershell/latest/workspace/reference/libtmux-workspace-import-tmuxworkspace/)
- [`Resolve-TmuxWorkspace`](/en/powershell/latest/workspace/reference/libtmux-workspace-resolve-tmuxworkspace/)
- [`ConvertTo-TmuxWorkspaceJson`](/en/powershell/latest/workspace/reference/libtmux-workspace-convertto-tmuxworkspacejson/)

## Examples

Example 1

Convert a two-pane declaration for storage or inspection.

[Source example](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux.Workspace/ConvertTo-TmuxWorkspaceYaml.md).

```powershell
LibTmux.Workspace\Import-TmuxWorkspace -Yaml @'
session_name: development
windows:
  - window_name: work
    panes: [nvim, ""]
'@ | LibTmux.Workspace\ConvertTo-TmuxWorkspaceYaml
```

## Parameters

- `Workspace` (`LibTmux.Workspace.WorkspaceFile`): The native declaration to serialize without applying it.
  Required. Position 0. Accepts pipeline input by value. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?view=powershellsdk-7.4.0).
- `Verbose` (`System.Management.Automation.SwitchParameter`): Display verbose messages produced by this command.
  Optional. Named parameter. Switch parameter. Common parameter. Does not accept pipeline input. Aliases: `vb`.
- `Debug` (`System.Management.Automation.SwitchParameter`): Display debug messages produced by this command.
  Optional. Named parameter. Switch parameter. Common parameter. Does not accept pipeline input. Aliases: `db`.
- `ErrorAction` (`System.Management.Automation.ActionPreference`): Choose how this command responds to non-terminating errors.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ea`.
- `WarningAction` (`System.Management.Automation.ActionPreference`): Choose how this command responds to warning messages.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `wa`.
- `InformationAction` (`System.Management.Automation.ActionPreference`): Choose how this command handles information messages.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `infa`.
- `ProgressAction` (`System.Management.Automation.ActionPreference`): Choose how this command handles progress updates.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `proga`.
- `ErrorVariable` (`System.String`): Store the command's error records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ev`.
- `WarningVariable` (`System.String`): Store the command's warning records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `wv`.
- `InformationVariable` (`System.String`): Store the command's information records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `iv`.
- `OutVariable` (`System.String`): Save output in the named variable while passing it down the pipeline.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ov`.
- `OutBuffer` (`System.Int32`): Buffer output before passing it to the next pipeline command.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ob`.
- `PipelineVariable` (`System.String`): Make the most recent output object available through a named variable within the pipeline.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `pv`.

## Returns

`System.String`: One YAML document per input declaration.
