<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "USDKit",
  "identifier" : "/documentation/USDKit/USDStage/exportFlattened(to:)-98kpc",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "USDKit"
    ],
    "preciseIdentifier" : "s:6USDKit8USDStageV15exportFlattened2toy10Foundation3URLV_tKF"
  },
  "title" : "exportFlattened(to:)"
}
-->

# exportFlattened(to:)

Exports the stage as a flattened USD file.

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

## 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`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)