Buffer
Buffer.from(string)
Encodes a string into a Buffer. UTF-8 is the default. Other overloads accept arrays, buffers and ArrayBuffers with different copy/sharing semantics.
Formal Syntax & Structure
nodejs syntaxnodejs
Buffer.from(string[, encoding])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| string | string | Text to encode. |
| encoding | string | Source encoding, default utf8. |
Return Value
Buffer
New Buffer for this string overload.
Working Example
Example Snippetnodejs
import { Buffer } from "node:buffer";console.log(Buffer.from("café", "utf8").toString("hex"));