Inferensys

Prompt

Fullwidth to Halfwidth Character Normalization Prompt

A practical prompt playbook for using Fullwidth to Halfwidth Character Normalization Prompt in production AI workflows.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Define the exact job, the ideal user, and the constraints for fullwidth-to-halfwidth character normalization.

This prompt is for internationalization engineers and platform developers who receive model-generated text containing mixed fullwidth and halfwidth characters. The core job-to-be-done is converting fullwidth characters (e.g., 'A', '9', '!') to their halfwidth equivalents (e.g., 'A', '9', '!') to ensure consistent text alignment, search indexing, string comparison, and downstream system compatibility. This is not a general text cleanup prompt—it targets the specific encoding mismatch that occurs when models trained on multilingual corpora output CJK fullwidth forms in contexts that require ASCII-compatible halfwidth characters.

Use this prompt when your application must normalize text for systems that treat fullwidth and halfwidth characters as distinct code points—breaking SQL queries, search indexes, regex patterns, log parsers, or fixed-width display fields. The prompt is designed for post-generation repair: you receive a model output that is structurally valid but contains character-width inconsistencies, and you need a deterministic normalization pass before the text enters your application logic. The ideal user has a clear target script (Latin, digits, punctuation) and knows whether they need fullwidth-to-halfwidth conversion, halfwidth-to-fullwidth conversion, or bidirectional normalization. Required context includes the target character set, any characters that must be preserved in their original width, and the expected output encoding.

Do not use this prompt for general Unicode normalization (NFC/NFD/NFKC/NFKD), which handles canonical equivalence but does not specifically address character width. Do not use it when the distinction between fullwidth and halfwidth forms carries semantic meaning in the target domain—for example, in Japanese typography where fullwidth characters are intentional, or in legacy systems that require fullwidth forms for display. This prompt is also inappropriate for handling emoji width, combining characters, or bidirectional text layout issues. Before applying this prompt, verify that your downstream system actually requires width normalization; many modern systems handle fullwidth characters correctly, and unnecessary normalization can introduce data loss. For high-risk contexts such as financial identifiers, legal document text, or medical records, always implement a human review step after normalization to confirm that no semantically significant characters were altered.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works, where it fails, and the operational risks to manage before wiring it into a production pipeline.

01

Good Fit: CJK Text Alignment Repair

Use when: model outputs contain mixed fullwidth and halfwidth characters that break monospace alignment, column formatting, or fixed-width display in terminals, logs, or reports. Guardrail: always specify the target normalization direction (to halfwidth or to fullwidth) explicitly in the prompt constraints.

02

Good Fit: Search Index Normalization

Use when: fullwidth Latin letters, digits, or punctuation in model-generated content prevent exact-match search or string comparison from working correctly. Guardrail: apply normalization before indexing and before querying to maintain consistency; log pre- and post-normalization forms for debugging.

03

Bad Fit: Preserving Intentional Formatting

Avoid when: fullwidth characters carry semantic meaning—such as in Japanese vertical text, specific brand names, or user-authored content where the width is intentional. Guardrail: add a preservation list of strings or character ranges that must not be converted; validate against a golden set of known exceptions.

04

Bad Fit: Real-Time Streaming Pipelines

Avoid when: latency budget is under 50ms and the normalization prompt adds a full model round-trip. Guardrail: use a deterministic character-mapping library (e.g., Python's unicodedata or ICU) for real-time paths; reserve the prompt-based approach for batch repair of outputs that already failed deterministic normalization.

05

Required Input: Source Encoding Metadata

Risk: without knowing the original encoding, the prompt may misclassify characters or apply wrong conversion rules. Guardrail: always pass the detected or declared encoding alongside the text; if encoding is unknown, run a detection step first and include the confidence score in the prompt context.

06

Operational Risk: Silent Data Corruption

Risk: the model may convert characters incorrectly without raising errors, producing valid-looking but semantically wrong text that propagates downstream. Guardrail: implement a round-trip check—convert to target width and back, then compare against the original; flag any divergence above a threshold for human review.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template with square-bracket placeholders for normalizing fullwidth characters to halfwidth in model outputs.

This prompt template is designed to be copied directly into your application or evaluation harness. It instructs the model to convert fullwidth characters—common in CJK text environments—into their standard halfwidth equivalents. The template uses square-bracket placeholders for all dynamic inputs, making it safe to wrap in your own string formatting or template engine without conflicting with the model's native token syntax.

text
You are a text normalization engine. Your task is to convert all fullwidth characters in the provided [INPUT_TEXT] to their standard halfwidth equivalents.

Follow these rules strictly:
1. Convert fullwidth alphanumeric characters (U+FF10-U+FF19, U+FF21-U+FF3A, U+FF41-U+FF5A) to standard ASCII alphanumerics.
2. Convert fullwidth punctuation and symbols to their halfwidth equivalents where unambiguous mappings exist. Do not convert characters that lack a standard halfwidth counterpart.
3. Preserve all other characters exactly as they appear, including CJK ideographs, kana, and hangul.
4. Do not alter whitespace, line breaks, or the structural layout of the text.
5. Return ONLY the normalized text. Do not add explanations, notes, or markdown formatting.

[INPUT_TEXT]:
[USER_INPUT]

To adapt this template, replace [USER_INPUT] with the text requiring normalization. If your target system requires fullwidth output instead of halfwidth, reverse the instruction. For high-risk pipelines—such as financial record processing or legal document ingestion—add a [CONSTRAINTS] block specifying characters that must never be converted, and always validate the output against a known-character allowlist before ingestion. For CJK-specific edge cases, extend the rules to handle fullwidth currency symbols (¥ to ¥), fullwidth parentheses, or the fullwidth space (U+3000) to halfwidth space conversion based on your system's requirements.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Fullwidth to Halfwidth Character Normalization Prompt. Each placeholder must be supplied by the calling application or upstream pipeline before the prompt is assembled and sent to the model.

PlaceholderPurposeExampleValidation Notes

[INPUT_TEXT]

The raw string containing mixed fullwidth and halfwidth characters that needs normalization.

Hello World!

Must be a non-null string. Empty string is allowed and should produce an empty output. Validate length does not exceed model context window minus prompt overhead.

[TARGET_SCRIPT]

Specifies the character script context to apply correct normalization rules.

CJK

Must be one of an allowed enum: CJK, Latin, Arabic, Cyrillic, or null. When null, the model should auto-detect. Invalid values must cause the harness to abort before the model call.

[NORMALIZATION_DIRECTION]

Determines whether to convert characters to halfwidth, fullwidth, or both.

to_halfwidth

Must be one of: to_halfwidth, to_fullwidth, or auto. The auto setting should preserve the dominant width in the input. Reject any other value at the harness level.

[PRESERVE_EXCEPTIONS]

A list of specific characters or Unicode ranges that should not be normalized, overriding the default rules.

["U+3000", "U+FF0C"]

Must be a valid JSON array of strings. Each string must be a valid Unicode code point (U+XXXX) or a literal character. Invalid entries should cause a harness error. An empty array is allowed.

[OUTPUT_FORMAT]

Defines the structure of the model response for downstream parsing.

json

Must be one of: json, text. When json, the model must return a JSON object with normalized_text and replacement_log fields. The harness must validate the response against this schema.

[TARGET_SYSTEM]

Identifies the downstream system consuming the output, used to apply system-specific compatibility rules.

postgres_utf8

Must be a non-empty string matching a known system identifier in the harness config. Unknown values should trigger a warning but not abort. Used to select post-processing rules like ASCII fallback for legacy systems.

PROMPT PLAYBOOK

Implementation Harness Notes

A practical guide to wiring the Fullwidth to Halfwidth Character Normalization Prompt into a production application with validation, retries, and observability.

This prompt is designed to be a post-processing step in a text pipeline, not a standalone interactive tool. It should be called after a primary model generates text that may contain mixed fullwidth and halfwidth characters. The typical integration point is inside a validation or repair layer that sits between the primary model's output and the downstream consumer (a search index, a database, a UI component, or a comparison function). The harness should treat this normalization as a deterministic cleanup operation, but because it relies on an LLM, it must be wrapped with the same rigor as any other model call: idempotency checks, retry logic, and output validation.

To wire this into an application, start by defining a clear contract. The input to the harness should be a string ([INPUT]) and a target normalization rule ([TARGET], e.g., 'halfwidth' or 'fullwidth'). The harness should first perform a fast, pre-flight check using a Unicode character class regex. If the input already matches the target (e.g., no fullwidth characters are detected when halfwidth is requested), skip the LLM call entirely and return the original string. This saves cost and latency. If the LLM is called, the output must be validated: check that the character length is preserved (unless the normalization rule explicitly changes it), and verify that no illegal character classes remain. For CJK text, a critical validation step is to ensure that characters which do not have a halfwidth equivalent (such as most Kanji) are left untouched. A post-validation script should flag any output where the ratio of fullwidth to halfwidth characters hasn't shifted in the expected direction.

For retry logic, implement a maximum of two retries with exponential backoff. The most common failure mode is the model applying the rule too broadly (e.g., converting Latin letters but not digits, or vice versa) or too narrowly (missing some fullwidth punctuation). On the first retry, append the validation error message to the prompt as additional [CONSTRAINTS]. On the second failure, log the input, the failed outputs, and the validation errors as a structured event, then fall back to a deterministic, rule-based normalizer (such as Python's unicodedata.normalize with NFKC followed by a character mapping table). This hybrid approach ensures that the system remains reliable even when the model behaves unexpectedly. Never retry indefinitely; a rule-based fallback is always the final safety net for this deterministic task.

Model choice matters less for this task than for generative work, but consistency does. A smaller, faster, and cheaper model is often sufficient. Test the prompt against a golden dataset of 100+ mixed-encoding strings, including edge cases like fullwidth spaces (U+3000), fullwidth digits inside otherwise halfwidth text, and strings with combining characters. Record the exact model version and configuration. Before any model upgrade, rerun this golden set to detect normalization drift. Finally, ensure all inputs and outputs are logged in a structured format that includes the pre-flight check result, the model's raw response, the validation result, and the final output. This trace is essential for debugging silent corruption in downstream systems.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact shape, types, and validation rules for the normalized output. Use this contract to build an automated post-processing harness that rejects malformed responses before they reach downstream systems.

Field or ElementType or FormatRequiredValidation Rule

normalized_text

string

Must contain only halfwidth characters per the target script. No fullwidth codepoints in the U+FF00–U+FFEF range unless explicitly preserved by [EXCEPTION_LIST].

original_text

string

Must match the [INPUT_TEXT] byte-for-byte. Used for audit trail and round-trip verification.

transformations_applied

array of objects

Each object must have 'character' (string), 'original_codepoint' (string like U+FF21), 'replacement_codepoint' (string like U+0041), and 'position' (integer). Array must not be empty if changes occurred.

transformations_count

integer

Must equal the length of transformations_applied. Must be >= 0. If 0, normalized_text must equal original_text.

script_type

string

Must be one of: 'halfwidth', 'fullwidth', 'mixed'. If 'mixed', the [TARGET_SCRIPT] constraint was not fully satisfiable and the exceptions field must be populated.

exceptions

array of strings

Required when script_type is 'mixed'. Each entry must describe a character and the reason it was not converted (e.g., 'U+FF0C preserved per EXCEPTION_LIST entry 3').

processing_notes

string

Free text for edge cases. Must not contain the original fullwidth input if [REDACT_INPUT_IN_LOG] is true.

PRACTICAL GUARDRAILS

Common Failure Modes

Fullwidth-to-halfwidth normalization seems simple, but character ambiguity, context-dependent rules, and downstream system expectations create sharp edges. These are the most common failures and how to prevent them.

01

Over-Normalization of CJK Punctuation

What to watch: The prompt aggressively converts fullwidth punctuation (、。「」) to halfwidth equivalents (,.[]), breaking Japanese and Chinese grammar where fullwidth punctuation is standard. Guardrail: Add a language-aware exclusion list in the prompt constraints. For CJK text, preserve fullwidth punctuation and only normalize alphanumeric and Latin-script characters.

02

Ambiguous Character Width in Mixed Scripts

What to watch: Characters like the fullwidth dollar sign ($) or percent (%) are visually identical to halfwidth in some fonts but break string comparison, regex, and database lookups. Guardrail: Include explicit mapping tables in the prompt for the specific ambiguous characters your downstream system rejects. Validate output with a character-by-character width audit before ingestion.

03

Broken String Length and Alignment

What to watch: Normalization changes the byte length and display width of strings, causing fixed-width UI columns, log formatters, or monospace reports to misalign. Guardrail: Pair the normalization prompt with a post-processing check that measures the visual width of the output string against the target system's column constraints. Flag outputs that exceed limits.

04

Loss of Intentional Fullwidth Formatting

What to watch: Some systems use fullwidth characters deliberately for visual emphasis, form field alignment, or legacy compatibility. Blind normalization destroys that intent. Guardrail: Require the prompt to accept a [PRESERVATION_RULES] parameter that lists contexts or character ranges to skip. Default to conservative normalization that only targets known-problematic ranges.

05

Katakana and Hiragana Width Confusion

What to watch: Fullwidth katakana (カ) and halfwidth katakana (カ) are distinct Unicode code points with different normalization rules than Latin fullwidth characters. Treating them identically corrupts Japanese text. Guardrail: Add a dedicated normalization path for kana in the prompt instructions. Use NFKC normalization as a baseline but verify kana-specific behavior with a test set of mixed-width Japanese strings.

06

Silent Data Corruption in Comparison Logic

What to watch: After normalization, strings that were visually distinct may become identical, or strings that should match may still differ due to incomplete normalization. This breaks deduplication, foreign key joins, and search indexing. Guardrail: Run a pre- and post-normalization diff on a sample of production data. Include eval checks that verify canonical equivalence for known-match pairs and preserved distinctness for known-mismatch pairs.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Fullwidth to Halfwidth Character Normalization Prompt before shipping. Each criterion targets a specific failure mode common in CJK normalization workflows.

CriterionPass StandardFailure SignalTest Method

ASCII Character Preservation

All standard ASCII alphanumeric and punctuation characters in [INPUT] remain unchanged in the output.

ASCII characters like 'A', '1', or '.' are converted to fullwidth forms ('A', '1', '。') or otherwise corrupted.

Diff the ASCII subset of [INPUT] against the output. Assert zero changes for characters in the U+0020–U+007E range.

Fullwidth Alphanumeric Conversion

All fullwidth letters (A-Z, a-z) and digits (0-9) are converted to their standard halfwidth equivalents.

Fullwidth alphanumeric characters remain in the output, or are converted to incorrect halfwidth characters.

Scan output for any character in the U+FF01–U+FF5E range. Assert none remain. Spot-check known fullwidth inputs.

Fullwidth Punctuation Normalization

Fullwidth punctuation (,。!?"#$%&'()*+,-./:;<=>?@[\]^_`{|}~) is converted to halfwidth equivalents per [TARGET_SYSTEM] rules.

Fullwidth commas, periods, or brackets remain in output, breaking downstream parsers that expect ASCII punctuation.

Provide [INPUT] with fullwidth punctuation. Assert output contains only halfwidth equivalents. Validate against a known mapping table.

Katakana Preservation

Halfwidth katakana (ヲ-゚) is correctly converted to fullwidth katakana (ヲ-ヶ) if [TARGET_SYSTEM] requires it, or left as-is if halfwidth is specified.

Katakana is converted to the wrong width, garbled, or treated as ASCII punctuation.

Include a test case with halfwidth katakana. Assert output matches the expected width per [TARGET_SYSTEM] configuration. Check boundary characters like 。「」、・.

Hangul Jamo Integrity

Hangul compatibility jamo (U+3130–U+318F) and syllables are never decomposed or corrupted by the normalization pass.

Hangul characters are incorrectly mapped to halfwidth forms, decomposed into individual jamo, or replaced with placeholder characters.

Provide [INPUT] containing mixed Hangul and fullwidth punctuation. Assert Hangul characters are byte-identical in the output.

Mixed-Width String Round-Trip

A string containing a mix of halfwidth ASCII, fullwidth punctuation, and CJK ideographs is normalized without data loss or corruption.

Output length changes unexpectedly, CJK ideographs are altered, or spaces are collapsed/expanded incorrectly.

Construct a known mixed-width string. Assert output matches a pre-computed expected string exactly. Check character count and byte length.

Whitespace Handling

Fullwidth space (U+3000) is converted to halfwidth space (U+0020). Other whitespace characters (tabs, newlines) are preserved as-is.

Fullwidth spaces remain in output, or standard spaces are incorrectly collapsed or expanded.

Include [INPUT] with fullwidth spaces between CJK characters and ASCII words. Assert U+3000 is replaced with U+0020. Assert tab and newline characters are unchanged.

Empty and Edge-Case Inputs

Empty string, whitespace-only string, and strings with only fullwidth characters are handled without error or hallucination.

Prompt returns an error message, hallucinates content, or produces a null output for valid edge-case inputs.

Run test cases: empty string, single fullwidth space, single fullwidth character. Assert valid, non-null output that matches expected normalization.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base normalization prompt and a single target script (e.g., halfwidth only). Use a small test set of mixed CJK and ASCII strings. Skip strict schema validation initially—focus on whether the model correctly maps fullwidth characters to their halfwidth equivalents.

code
Normalize all fullwidth characters in [INPUT_TEXT] to halfwidth equivalents.
Preserve all other characters unchanged.
Return only the normalized text.

Watch for

  • The model converting halfwidth characters back to fullwidth when you only asked for one direction
  • Katakana-specific normalization rules being missed (fullwidth katakana to halfwidth katakana is a distinct mapping)
  • The model adding explanations or commentary instead of returning raw normalized text
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.