--- type: "fhirpath-function" title: "FHIRPath Function: escape" function: "escape" category: "Additional String Functions" section: "5.7.3" source: "fhirpath/functions.json" --- # FHIRPath Function: escape {:.stu} The escape function takes a singleton string and escapes it for a given target, as specified in the following table: {:.stu} |html |The string is escaped such that it can appear as valid HTML content (at least open bracket (`<`), ampersand (`&`), and quotes (`"`), but ideally anything with a character encoding above 127) | |=|=| |json |The string is escaped such that it can appear as a valid JSON string (quotes (`"`) are escaped as (`\"`)); additional escape characters are described in the [String](#string) escape section| {:.grid} {:.stu} If the input is empty, the result is empty. {:.stu} If no target is specified, the result is empty. {:.stu} ## Summary - **Category**: Additional String Functions - **Section**: `5.7.3` - **Return Type**: `String` - **Empty Input Result**: `empty` - **Errors on Multiple Input**: `true` ## Description The escape function takes a singleton string and escapes it for a given target. Available targets are html and json. ## Arguments - `target`: `String` - Target format (html, json) ## Type Mapping - `String-String` ## Example ```fhirpath '"test"'.escape('json') // returns '\"test\"' ```