# normalize_tool_arguments

> **Function** in `langchain_ibm`

📖 [View in docs](https://reference.langchain.com/python/langchain-ibm/utils/normalize_tool_arguments)

Ensure arguments is always a proper JSON string with robust error handling.

Handles various malformed inputs from LLMs including:
- Valid JSON strings
- Python dict strings (e.g., "{'key': 'value'}")
- Multiple layers of JSON wrapping (e.g., '"{\\"key\\": \\"value\\"}"')
- Malformed outputs with trailing characters (e.g., '"{}""}')
- Unbalanced braces
- Empty or invalid inputs

## Signature

```python
normalize_tool_arguments(
    args_str: str,
) -> str
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `args_str` | `str` | Yes | Tool call arguments string (potentially malformed from LLM) |

## Returns

`str`

Valid JSON string. Returns "{}" as fallback for unparseable input.

---

[View source on GitHub](https://github.com/langchain-ai/langchain-ibm/blob/629c50b31dcb6369911ae60a84348719053d9172/libs/ibm/langchain_ibm/utils.py#L265)