<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "JavaScriptCore",
  "identifier" : "/documentation/JavaScriptCore/JSStringRef",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:@T@JSStringRef"
  },
  "title" : "JSStringRef"
}
-->

# JSStringRef

A UTF-16 character buffer.

```
typealias JSStringRef = OpaquePointer
```

## Discussion

This is the fundamental string representation in JavaScript.

## Topics

### Creating a JavaScript String

[`JSStringCreateWithCharacters(_:_:)`](/documentation/JavaScriptCore/JSStringCreateWithCharacters(_:_:))

Creates a JavaScript string from a buffer of Unicode characters.

[`JSChar`](/documentation/JavaScriptCore/JSChar)

A Unicode character.

[`JSStringCreateWithUTF8CString(_:)`](/documentation/JavaScriptCore/JSStringCreateWithUTF8CString(_:))

Creates a JavaScript string from a null-terminated UTF-8 string.

[`JSStringRetain(_:)`](/documentation/JavaScriptCore/JSStringRetain(_:))

Retains a JavaScript string.

[`JSStringRelease(_:)`](/documentation/JavaScriptCore/JSStringRelease(_:))

Releases a JavaScript string.

### Accessing JavaScript String Information

[`JSStringGetLength(_:)`](/documentation/JavaScriptCore/JSStringGetLength(_:))

Returns the number of Unicode characters in a JavaScript string.

[`JSStringGetCharactersPtr(_:)`](/documentation/JavaScriptCore/JSStringGetCharactersPtr(_:))

Returns a pointer to the Unicode character buffer that serves as the backing store for a JavaScript string.

[`JSStringGetMaximumUTF8CStringSize(_:)`](/documentation/JavaScriptCore/JSStringGetMaximumUTF8CStringSize(_:))

Returns the maximum number of bytes a JavaScript string uses when you convert it into a null-terminated UTF-8 string.

[`JSStringGetUTF8CString(_:_:_:)`](/documentation/JavaScriptCore/JSStringGetUTF8CString(_:_:_:))

Converts a JavaScript string into a null-terminated UTF-8 string, and copies the result into an external byte buffer.

### Comparing JavaScript Strings

[`JSStringIsEqual(_:_:)`](/documentation/JavaScriptCore/JSStringIsEqual(_:_:))

Tests whether two JavaScript strings match.

[`JSStringIsEqualToUTF8CString(_:_:)`](/documentation/JavaScriptCore/JSStringIsEqualToUTF8CString(_:_:))

Tests whether a JavaScript string matches a null-terminated UTF-8 string.

### Converting to and from Core Foundation Strings

[`JSStringCreateWithCFString(_:)`](/documentation/JavaScriptCore/JSStringCreateWithCFString(_:))

Creates a JavaScript string from a Core Foundation string.

[`JSStringCopyCFString(_:_:)`](/documentation/JavaScriptCore/JSStringCopyCFString(_:_:))

Creates a Core Foundation string from a JavaScript string.



---

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)