---
title: "XMLFORMAT"
description: "The XMLFORMAT SQL function pretty-prints xml text."
language: en
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/xmlformat
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/xmlformat
updated: 2026-08-09T00:00:00Z
license: https://documentation.invantive.eu/en/
---

## Syntax
```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> XMLFORMAT[XMLFORMAT]:::quoted
    XMLFORMAT --> End((END))
```

## Purpose
The `XMLFORMAT` SQL function pretty-prints xml text.

See also [[XMLCOMMENT]], [[XMLDECODE]], [[XMLELEMENT]], [[XMLENCODE]] and [[XMLTRANSFORM]].

Parameters:
- Xml (`varchar2`): xml to pretty-print.

Returns: the pretty-printed XML text.

## Examples
The following example pretty-prints a compact XML text:
```sql
select xmlformat('<r><name>peter</name></r>')

-------------------
<?xml version="1.0" encoding="utf-8"?>
<r>
  <name>peter</name>
</r>
```
The following example raises an error since the XML text is invalid; the end tag `c` does not match the start tag `a`:
```sql
select xmlformat('<root><a>b</c></root>')

itgenxml120: XML formatting failed.
```