---
title: "exportFlattened(to:)"
framework: usdkit
role: symbol
role_heading: Instance Method
path: "usdkit/usdstage-4sfi1/exportflattened(to:)-98kpc"
---

# exportFlattened(to:)

Exports the stage as a flattened USD file.

## Declaration

```swift
func exportFlattened(to url: URL) throws
```

## Discussion

Discussion Composes all layers into a single layer and writes it to the specified location. The output format is determined by the file extension. important: Flattening is destructive. Layer structure, composition arcs, and variant selections are resolved into the output. To preserve layer structure, use exportPackage(to:options:) instead. Throws an error if the extension is not .usda, .usdc, or .usd.

## See Also

### Exporting the stage

- [exportPackage(to:options:)](usdkit/usdstage-4sfi1/exportpackage(to:options:)-6s2wk.md)
- [exportPackage(to:options:)](usdkit/usdstage-4sfi1/exportpackage(to:options:)-2x7yr.md)
- [exportFlattened(to:)](usdkit/usdstage-4sfi1/exportflattened(to:)-6717d.md)
- [USDStage.ExportOptions](usdkit/usdstage-4sfi1/exportoptions.md)
