---
title: "safeDecodeURIComponent"
description: "Decode a URI component safely, returning the original string instead of throwing when the input contains malformed escape sequences."
canonical_url: "https://core.mhaibaraai.cn/en/docs/utilities/url/safe-decode-uri-component"
---
# safeDecodeURIComponent

> Decode a URI component safely, returning the original string instead of throwing when the input contains malformed escape sequences.

## Usage

`safeDecodeURIComponent` decodes a URI component safely — returning the original string on failure instead of throwing.

```ts
import { safeDecodeURIComponent } from '@movk/core'

safeDecodeURIComponent('%E4%B8%AD%E6%96%87') // '中文'
safeDecodeURIComponent('hello%20world') // 'hello world'
safeDecodeURIComponent('%invalid%') // '%invalid%'
```

## API

### `safeDecodeURIComponent(str)`

Decode a URI component (safe version).

### Parameters

**str** (`string`) *required*: The string to decode.

### Returns

**returns** (`string`): The decoded string.

## Changelog

See commit history for [src/utilities/url/transform.ts](https://github.com/mhaibaraai/movk-core/commits/main/src/utilities/url/transform.ts).

---

- [GitHub](https://github.com/mhaibaraai/movk-core/blob/main/src/utilities/url/transform.ts)


## Sitemap

See the full [sitemap](https://core.mhaibaraai.cn/sitemap.md) for all pages.
