<!--
{
  "availability" : [
    "macOS: 10.3.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WebDocumentRepresentation/documentSource()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WebDocumentRepresentation(im)documentSource"
  },
  "title" : "documentSource()"
}
-->

# documentSource()

Returns the receiver’s source as text.

```
func documentSource() -> String!
```

## Return Value

Returns the document source associated with the receiver or `nil` if the source cannot be provided.

## Discussion

For example, for HTML documents, the receiver should return the HTML source.

---

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)