<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/JSONSerialization/WritingOptions",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@E@NSJSONWritingOptions"
  },
  "title" : "JSONSerialization.WritingOptions"
}
-->

# JSONSerialization.WritingOptions

Options for writing JSON data.

```
struct WritingOptions
```

## Topics

### Creating a Writing Options Instance

[`init(rawValue:)`](/documentation/Foundation/JSONSerialization/WritingOptions/init(rawValue:))

Creates a set of JSON formatting options from an integer that represents those options.

### Formatting JSON

[`NSJSONWritingFragmentsAllowed`](/documentation/Foundation/JSONSerialization/WritingOptions/fragmentsAllowed)

Specifies that the parser should allow top-level objects that aren’t arrays or dictionaries.

[`NSJSONWritingPrettyPrinted`](/documentation/Foundation/JSONSerialization/WritingOptions/prettyPrinted)

Specifies that the output uses white space and indentation to make the resulting data more readable.

[`NSJSONWritingSortedKeys`](/documentation/Foundation/JSONSerialization/WritingOptions/sortedKeys)

Specifies that the output sorts keys in lexicographic order.

[`NSJSONWritingWithoutEscapingSlashes`](/documentation/Foundation/JSONSerialization/WritingOptions/withoutEscapingSlashes)

Specifies that the output doesn’t prefix slash characters with escape characters.

## Relationships

### Conforms To

[`SetAlgebra`](/documentation/Swift/SetAlgebra)

[`ExpressibleByArrayLiteral`](/documentation/Swift/ExpressibleByArrayLiteral)

[`Sendable`](/documentation/Swift/Sendable)

[`BitwiseCopyable`](/documentation/Swift/BitwiseCopyable)

[`OptionSet`](/documentation/Swift/OptionSet)

[`RawRepresentable`](/documentation/Swift/RawRepresentable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Equatable`](/documentation/Swift/Equatable)

---

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)