DMS to Decimal Coordinates API: The Complete Guide

Need to convert coordinates from degrees, minutes, seconds (DMS) format to decimal degrees? This guide covers everything about DMS to decimal conversion via API, including the conversion formula, common formats, and implementation examples.

What is DMS Format?

DMS (Degrees, Minutes, Seconds) is a traditional way of expressing geographic coordinates. Each degree is divided into 60 minutes, and each minute into 60 seconds.

For example, the coordinates of New York City can be expressed as:

  • DMS: 40° 42' 46" N, 74° 0' 22" W
  • Decimal: 40.7128°, -74.0060°

The Conversion Formula

To convert DMS to decimal degrees:

Decimal Degrees = Degrees + (Minutes / 60) + (Seconds / 3600)

For southern latitudes (S) or western longitudes (W), the result is negative.

Example: 40° 42' 46" N = 40 + (42/60) + (46/3600) = 40.7128°

Using the DMS to Decimal API

TinyFn provides a simple endpoint to convert DMS coordinates:

API Request
POST https://api.tinyfn.io/v1/geo/dms-to-decimal
Headers: X-API-Key: your-api-key
Content-Type: application/json

{
  "latitude": {
    "degrees": 40,
    "minutes": 42,
    "seconds": 46,
    "direction": "N"
  },
  "longitude": {
    "degrees": 74,
    "minutes": 0,
    "seconds": 22,
    "direction": "W"
  }
}
Response
{
  "decimal": {
    "lat": 40.7128,
    "lng": -74.0061
  },
  "formatted": "40.7128, -74.0061"
}

Parameters

Parameter Type Description
latitude object DMS latitude with degrees, minutes, seconds, direction
longitude object DMS longitude with degrees, minutes, seconds, direction
dms_string string Alternative: full DMS string to parse (e.g., "40°42'46\"N, 74°0'22\"W")
precision integer Decimal precision (default: 6)

Code Examples

JavaScript / Node.js

const response = await fetch(
  'https://api.tinyfn.io/v1/geo/dms-to-decimal',
  {
    method: 'POST',
    headers: {
      'X-API-Key': 'your-api-key',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      latitude: { degrees: 40, minutes: 42, seconds: 46, direction: 'N' },
      longitude: { degrees: 74, minutes: 0, seconds: 22, direction: 'W' }
    })
  }
);
const { decimal } = await response.json();
console.log(decimal); // { lat: 40.7128, lng: -74.0061 }

Python

import requests

response = requests.post(
    'https://api.tinyfn.io/v1/geo/dms-to-decimal',
    headers={'X-API-Key': 'your-api-key'},
    json={
        'latitude': {'degrees': 40, 'minutes': 42, 'seconds': 46, 'direction': 'N'},
        'longitude': {'degrees': 74, 'minutes': 0, 'seconds': 22, 'direction': 'W'}
    }
)
decimal = response.json()['decimal']
print(decimal)  # {'lat': 40.7128, 'lng': -74.0061}

cURL

curl -X POST "https://api.tinyfn.io/v1/geo/dms-to-decimal" \
  -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "latitude": {"degrees": 40, "minutes": 42, "seconds": 46, "direction": "N"},
    "longitude": {"degrees": 74, "minutes": 0, "seconds": 22, "direction": "W"}
  }'

Common Use Cases

  • GPS Data Processing: Convert GPS coordinates from DMS to decimal for mapping APIs
  • Survey Data Import: Process surveying data that uses DMS format
  • Legacy System Integration: Convert coordinates from older systems using DMS
  • User Input Processing: Allow users to enter coordinates in DMS format
  • Document Parsing: Extract and convert coordinates from documents

Best Practices

  1. Handle multiple formats: Use the string parser for user-entered coordinates
  2. Validate direction: Ensure direction is N/S for latitude and E/W for longitude
  3. Check value ranges: Degrees (0-90 lat, 0-180 lng), Minutes (0-59), Seconds (0-59.99)
  4. Preserve precision: Use appropriate decimal precision for your use case

Use via MCP

Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:

{
  "mcpServers": {
    "tinyfn-geo": {
      "url": "https://api.tinyfn.io/mcp/geo/",
      "headers": {
        "X-API-Key": "your-api-key"
      }
    }
  }
}

See all geolocation tools available via MCP in our Geolocation MCP Tools for AI Agents guide.

Try the DMS to Decimal API

Get your free API key and start converting coordinates in seconds.

Get Free API Key

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key