JS & SQL String Escape

JS & SQL String Escape

Generate or decode JavaScript string literals and PostgreSQL standard string literals. Handle quotes, backslashes, and line breaks without executing input.

Input and results are processed locally in your browser without upload or storage by this tool. XML and string inputs are not executed; results are shown as text. Shared site advertising and analytics may operate separately, but tool-use events do not include your input contents.

Comments & questions

JS & SQL String Escape

Represent text as a single- or double-quoted JavaScript literal, or as a PostgreSQL standard string literal. Decoding reads only that string syntax, without eval or SQL execution. General JSON string conversion remains available in the existing JSON formatter.

Key features

  • Choose JavaScript quote style and escape control characters.
  • Decode JavaScript Unicode escapes, hexadecimal escapes, and line continuations.
  • Double apostrophes for PostgreSQL standard strings while keeping backslashes as data.

How to use

  1. Choose the string syntax and encoding or decoding direction.
  2. Encode raw text, or decode one complete literal including its surrounding quotes.
  3. Review and copy the result. Use prepared statements and parameter binding for actual SQL values.

Use cases

  • Create JavaScript string fixtures for tests.
  • Read the contents of escaped string literals.
  • Learn apostrophe handling in PostgreSQL standard strings.

Frequently asked questions

Can it execute code or template literals?

No. Decoding accepts one single- or double-quoted string, not template literals, concatenation expressions, or function calls. Legacy octal escapes are not supported.

Which SQL dialect and settings does it use?

The SQL mode handles ordinary PostgreSQL single-quoted strings with standard_conforming_strings=on. E strings, dollar quoting, identifiers, and other database dialects are not supported. NUL characters are rejected.

Does this prevent SQL injection?

No. This is a string notation aid for learning and static examples, not an injection defense. Pass runtime values through your database driver’s parameter binding.

Are surrounding quotes required for decoding?

Yes. Include the JavaScript quotes selected in the options, or PostgreSQL single quotes. Encoding includes those quotes in its output. The limit is 100,000 UTF-16 code units.

Privacy

Input and results are processed locally in your browser without upload or storage by this tool. XML and string inputs are not executed; results are shown as text. Shared site advertising and analytics may operate separately, but tool-use events do not include your input contents.

References

Related Tools

HTML Entity ConverterUnicode Escape ConverterSQL FormatterWasm Module InspectorHreflang Matrix CheckerAST Query PlaygroundContainer Build GraphDependency Graph ExplorerSemver Range LabCron Schedule AuditorPatch Review WorkbenchSource Map ExplorerLocalization Catalog AuditorStructured Data ReviewerHTTP Archive AnalyzerWebhook Signature LabProtobuf Schema WorkbenchGraphQL Schema LabAvro Schema EvolutionLocal SQL WorkbenchSchema Form BuilderMesh Repair WorkbenchPipe Network LabRobot Arm Kinematics LabThermal Network LabBeam Response LabGear Train DesignerTolerance Stackup LabSensor Calibration FitPCB Stackup PlannerDigital Filter DesignerNetwork Reachability MapSun Shadow MapGPS Error SimulatorDigital Logic SimulatorAnalog Circuit LabMechanism Linkage LabAnalysis Mesh GeneratorOpenAPI Contract InspectorDatabase Migration PlannerDimensional Equation CheckerTruss Force LabBoolean Minimization LabControl Response LabQueueing Simulation LabGeofence Event SimulatorCoordinate Reference LabSurvey Traverse LabRaster Classification LabChoropleth Design LabMap Print ComposerRaster Reprojection LabElevation Contour MakerTerrain Viewshed LabWatershed DelineatorMap Tile PackagerText File Encoding WorkbenchFilesystem Portability AuditorSBOM License ExplorerFile Signature Auditornpm Lockfile Conflict ResolverSource Secret AuditorOffline Web Package BuilderCertificate Chain InspectorTorrent Metainfo InspectorChunked File PackagerEncrypted File VaultDuplicate File FinderArchive WorkbenchDesign Token ManagerSpacing Token DesignerResponsive Type SystemPackaging Dieline DesignerSVG Icon Sprite PackerFlex Layout PlaygroundCSS Grid PlaygroundRegex Equivalence LabMarkdown Repository AuditorLog Template MinerResponsive Layout AuditorEmail Template PreviewInternal Link GraphState Machine TesterPetri Net SimulatorGit History VisualizerCurl Request WorkbenchBinary Protocol DesignerHex File EditorBinary Patch WorkbenchFile Signature WorkbenchAPI Mock SandboxSchema Column MapperEvent Log SessionizerER Diagram DesignerTime Series Gap AuditorStratified Data SplitterData Lineage DesignerDecision Tree LabData Anonymization WorkbenchData Expectation RunnerJSON Schema ValidatorBasket Pattern AnalyzerRobots Policy TesterSEO HTML AuditorAccessibility Structure AuditorSyndication Feed WorkbenchIndexNow Payload BuilderCrawl Log AnalyzerCSP Policy WorkbenchSearch Performance AnalyzerCSV Formula Risk AuditorCORS Response SimulatorCache Header LabCookie Policy InspectorWeb Vitals Trace LabSitemap Health AuditorBatch File RenamerFile Manifest VerifierFolder Space MapFolder Difference ReviewerRoute Order OptimizerGeoJSON Map EditorPolygon Overlay LabCartographic Label PlacerSpatial Table JoinGeoJSON Topology AuditorGPX Track AnalyzerTrack Privacy RedactorCSV Table JoinCSV Pivot WorkbenchScientific Data ProfilerTabular Cleaning WorkbenchRecord ReconciliationData Dictionary BuilderCanonical Graph AuditorRedirect Plan TesterHTTP response and ping reference testBrowser and System InformationJSON ↔ YAML ConverterXML ↔ JSON ConverterHTML FormatterJavaScript MinifierMock Data Generator.gitignore GeneratorLicense GeneratorUser-Agent ParserPassword Strength CheckerCode to ImageXML FormatterHTTP Status Code LookupMIME Type LookupCSS Box Shadow GeneratorCSS Gradient GeneratorIndent ConverterNumber Base ConverterUnicode InspectorJSON Structure DiffMarkdown Table GeneratorBase64 EncoderJSON FormatterURL EncoderCron Expression GeneratorRegex TesterUUID GeneratorHash GeneratorTimestamp ConverterJWT DecoderMarkdown PreviewCSS MinifierMeta Tag GeneratorJSON ↔ CSVCase ConverterImage to Base64
Explore all Dev Tools tools →Image/Media →Text/Convert →Life/Fun →