# Unit Converter - Length, Weight, Temp & More, Any Alias (`eliai/unit-converter`) Actor

Physical-unit conversion by API: kg/kilos/kilogramme all resolve, temperature uses real formulas (212F = exactly 100C, release-tested), every result includes the value in ALL sibling units of its category, float noise stripped.

- **URL**: https://apify.com/eliai/unit-converter.md
- **Developed by:** [Broke to Built](https://apify.com/eliai) (community)
- **Categories:** Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.32 / 1,000 converted units

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Unit Converter — Length, Weight, Temperature & More, Alias-Tolerant

Convert physical units by API without memorizing canonical spellings: `kg`, `kilos`, `kilogramme`, `KG` all work. Categories cover length, weight, temperature (real formulas, not factors), volume, area and more — and every conversion also returns the value in **every sibling unit** of its category, so one call answers all the follow-ups. Up to 50 conversions per run, online, by API, or as an agent tool via Apify MCP.

Results are float-noise-free (12-significant-digit cleanup — you get `62.1371192237`, never `62.13711922369999`).

### What you get

- **result** — the requested conversion, noise-cleaned
- **allUnits** — the value in every unit of the category (100 km → meters, feet, miles, nautical miles... in one record)
- **category** + canonical `from`/`to` (so you see how your alias resolved)
- Temperature uses the actual formulas (F/C/K/Rankine) — 212°F is exactly 100°C, asserted by our release test
- **Fail-soft**: unknown units and incompatible categories (kg → miles) never fail the run — `{ok: false, error}` naming the problem, **never charged**.

### Input

```json
{ "value": 100, "from": "km", "to": "miles" }
```

Bulk: `{ "items": [{ "value": 212, "from": "fahrenheit", "to": "celsius" }, { "value": 2.5, "from": "kg", "to": "lb" }] }`

### Output (real run, trimmed)

```json
{
  "value": 100,
  "ok": true,
  "from": "kilometer",
  "to": "mile",
  "result": 62.1371192237,
  "category": "length",
  "allUnits": { "meter": 100000, "kilometer": 100, "mile": 62.1371192237, "foot": 328083.989501, "nautical-mile": 53.9956803456 }
}
```

### Pricing

**$0.0004 per conversion** — sibling-unit table included. Unknown/incompatible units are never charged.

Measured against the direct incumbent (2026-08-07): moving\_beacon/unit-converter-input charges $0.001 per item — this is under half that.

### Honest limits

- Physical measurement units only — no currency (rates change hourly; a static table would lie) and no timezone math (see our timestamp-converter).
- Incompatible categories are rejected with both categories named, never coerced.
- Precision: factors carry standard reference values (e.g. pound = 453.59237 g exactly); 12 significant digits returned.

### FAQ

**Which aliases work?**
The natural ones per unit — abbreviations (`kg`, `oz`, `mi`), plurals, and common spellings (`kilogramme`, `metre`). The output shows the canonical unit your alias resolved to.

**Why is temperature special?**
Because °F→°C is an affine formula, not a ratio — converters that treat it as a factor are simply wrong. This one implements the formulas and the release test proves 212°F = 100°C.

**What's allUnits for?**
Dashboards and agents: one conversion call gives the value in the whole category, so you render metric + imperial without a second request.

**Ton vs tonne?**
All three are distinct and supported: `us-ton` (short), `imperial-ton` (long), `metric-ton` (tonne) — aliases route `ton`→US, `tonne`→metric.

**Why did some rows come back `ok: false`?**
An unknown unit spelling, or a cross-category request like kg→miles — the error names exactly what happened. Never charged.

### Use from code or AI agents

```bash
curl -s "https://api.apify.com/v2/acts/EliAI~unit-converter/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -X POST -H 'Content-Type: application/json' \
  -d '{"items": [{"value": 5, "from": "miles", "to": "km"}, {"value": 350, "from": "F", "to": "C"}]}'
```

Agents: connect [Apify MCP](https://mcp.apify.com) and call the `EliAI/unit-converter` tool.

- **Capability:** alias-tolerant physical-unit conversion with per-category sibling tables and formula-correct temperature
- **Required input:** `value` + `from` + `to`, or `items` array
- **Returns:** one record per conversion; `result` + `allUnits` are the payload
- **Bounded:** 50 conversions per run; failures isolate per item
- **Side effects:** none

# Actor input Schema

## `value` (type: `number`):

The number to convert (used with 'from' and 'to'). For a single conversion, fill in value/from/to.

## `from` (type: `string`):

Source unit. Accepts full names or abbreviations, e.g. km, miles, kg, lb, celsius, f, liter, gal, m/s, mph, MB, GiB, hour, kWh.

## `to` (type: `string`):

Target unit (must be in the same category as 'from'). e.g. miles, lb, fahrenheit, gallon, mph, GiB, day.

## `category` (type: `string`):

Optional. Auto-detected from the units. Set to disambiguate. One of: length, weight, temperature, volume, area, speed, data, time, energy.

## `items` (type: `array`):

Convert many at once. Each item is an object: { "value": 100, "from": "f", "to": "c" }. Optional "category" per item.

## `maxItems` (type: `integer`):

Maximum number of conversions to perform in this run (cap).

## Actor input object example

```json
{
  "value": 100,
  "from": "km",
  "to": "miles",
  "category": "",
  "maxItems": 50
}
```

# Actor output Schema

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

Every item this run produced, as JSON.

## `resultsCsv` (type: `string`):

The same items as a spreadsheet-ready CSV.

# 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 = {
    "value": 100,
    "from": "km",
    "to": "miles"
};

// Run the Actor and wait for it to finish
const run = await client.actor("eliai/unit-converter").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 = {
    "value": 100,
    "from": "km",
    "to": "miles",
}

# Run the Actor and wait for it to finish
run = client.actor("eliai/unit-converter").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 '{
  "value": 100,
  "from": "km",
  "to": "miles"
}' |
apify call eliai/unit-converter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eliai/unit-converter"
        }
    }
}

```

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/B6Jdzuj9abbTaGORV/builds/gKYzglbV63ZqyJHYe/openapi.json
