# Japanese Text Normalizer (和暦・全角半角・郵便番号) (`petipeti/japanese-text-normalizer`) Actor

Clean Japanese text in bulk: full-width to half-width, half-width katakana, dashes, whitespace, postal codes, and Japanese era dates (令和/平成/昭和) to ISO dates. No scraping, no external calls.

- **URL**: https://apify.com/petipeti/japanese-text-normalizer.md
- **Developed by:** [peti peti](https://apify.com/petipeti) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 text normalizeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Japanese Text Normalizer (和暦・全角半角・郵便番号)

Clean messy Japanese text in bulk before you put it into a spreadsheet, database, search index or LLM pipeline.

**No scraping and no external requests.** The Actor only transforms the text you give it, so there are no site terms or personal-data collection concerns on our side.

### What it does

| Step | Example | Default |
|---|---|---|
| Full-width → half-width ASCII | `ＡＢＣ１２３` → `ABC123` | on |
| Half-width katakana → full-width | `ｶﾞｷﾞ` → `ガギ` | on |
| Ideographic space → space | `東京　都` → `東京 都` | on |
| Unify dashes (keeps the long vowel ー) | `03−1234–5678` → `03-1234-5678` | on |
| Collapse spaces, trim lines | | on |
| Postal code format | `〒1000001` → `〒100-0001` | on |
| Japanese era date → ISO | `令和6年4月1日` → `2024-04-01`, `R5.12.31` → `2023-12-31`, `平成元年` → `1989` | off |
| Kanji numerals → Arabic (experimental) | `三万五千円` → `35000円` | off |

Era dates (令和 / 平成 / 昭和 / 大正 / 明治, also `R6.4.1`, `H31.4.30` style) are **always detected and listed** in `warekiDates`, even when the rewrite option is off. Impossible dates (令和2年2月30日) and dates outside the era (平成31年5月1日) come back with a `warning` and are never rewritten.

Symbols such as ① or ㈱ are intentionally left as they are (unlike plain NFKC).

### Input

```json
{
  "texts": ["　令和６年４月１日　〒１００００１３", "ｶﾀｶﾅ　ＡＢＣ１２３"],
  "warekiToIso": true
}
```

### Output (one row per text)

```json
{
  "input": "　令和６年４月１日　〒１００００１３",
  "output": "2024-04-01 〒100-0013",
  "changed": true,
  "applied": ["width", "whitespace", "warekiToIso", "postalCodes"],
  "warekiDates": [{ "text": "令和6年4月1日", "era": "令和", "eraYear": 6, "iso": "2024-04-01", "warning": null }]
}
```

Download as JSON, CSV or Excel from the dataset tab, or call the Actor from the API / Make / Zapier / n8n.

### Use cases

- Cleaning Japanese CSV exports (CRM, EC, government open data) before import
- Converting 和暦 dates in documents and forms to ISO dates
- Preparing Japanese text for embeddings / RAG so full-width and half-width variants match

### Pricing

Pay per event, platform usage included:

| Event | Price |
|---|---|
| Actor start | $0.01 per run |
| `text-normalized` – one input text normalized | $0.50 per 1,000 texts |

Example: normalizing 10,000 texts costs $0.01 + $5.00 = $5.01.

### Limits

- Kanji numeral conversion is heuristic and off by default. Words such as 四国 can be changed. Check the output.
- Era years are converted using the first year of each era (令和1 = 2019, 平成1 = 1989, 昭和1 = 1926, 大正1 = 1912, 明治1 = 1868).

### 日本語での説明

日本語テキストの表記ゆれ（全角・半角、半角カナ、ダッシュ、空白、郵便番号）をまとめて整え、和暦（令和・平成・昭和など）を西暦の ISO 形式に直します。外部サイトへのアクセスは一切しません。

# Actor input Schema

## `texts` (type: `array`):

Japanese texts to normalize. One row is produced per text.

## `width` (type: `boolean`):

Full-width → half-width (ASCII), half-width katakana → full-width.

## `hyphens` (type: `boolean`):

Unify dashes to - (the long vowel ー is kept).

## `whitespace` (type: `boolean`):

Collapse spaces and trim lines.

## `postalCodes` (type: `boolean`):

Format postal codes (〒1000001 → 〒100-0001).

## `warekiToIso` (type: `boolean`):

Era dates are always reported in the warekiDates field. This option also rewrites them in the output text. Dates that do not exist or fall outside their era are reported with a warning and left unchanged.

## `kanjiNumbers` (type: `boolean`):

Heuristic. May change words that contain numerals (e.g. 四国). Review the output before using it.

## Actor input object example

```json
{
  "texts": [
    "　令和６年４月１日　〒１００００１３",
    "ｶﾀｶﾅ　ＡＢＣ１２３"
  ],
  "width": true,
  "hyphens": true,
  "whitespace": true,
  "postalCodes": true,
  "warekiToIso": false,
  "kanjiNumbers": false
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset items (Overview view).

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "texts": [
        "　令和６年４月１日　〒１００００１３",
        "ｶﾀｶﾅ　ＡＢＣ１２３"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("petipeti/japanese-text-normalizer").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "texts": [
        "　令和６年４月１日　〒１００００１３",
        "ｶﾀｶﾅ　ＡＢＣ１２３",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("petipeti/japanese-text-normalizer").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "texts": [
    "　令和６年４月１日　〒１００００１３",
    "ｶﾀｶﾅ　ＡＢＣ１２３"
  ]
}' |
apify call petipeti/japanese-text-normalizer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,petipeti/japanese-text-normalizer"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/U4z8M9wO3SB95GrXV/builds/QAWwzTgdDpA2qUApo/openapi.json
