Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

You can classify JSON, Base64, URI references, and timestamps with parsers and validators—no AI required. The key is to treat each result as a candidate match, not proof of what the string means: syntax can overlap, and context often decides which interpretation is useful.

Start with the original string and its context

Keep the input unchanged while checking it. Trimming whitespace, changing case, or normalizing characters before validation can hide what was actually supplied. Note where it came from—a field name, file format, protocol, or application profile—and what forms that context allows.

Then test the whole candidate against the relevant grammar or format. A useful classification records both the match and the rule used, such as “parses as JSON under a strict parser” or “valid Base64url under this application’s padding rules.” If several checks pass, preserve the ambiguity rather than guessing at the author’s intent.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to tell whether a string is JSON

Parse the entire candidate as JSON instead of looking only for braces or square brackets. RFC 8259 defines a JSON text as a serialized value, which can be an object, array, string, number, boolean, or null. A standalone number or quoted string can therefore be JSON even though it does not begin with { or [. See RFC 8259.

Use a parser configured for strict JSON if conformance matters. Some parsers accept extensions beyond the RFC grammar, so a successful parse by a permissive parser does not by itself establish that the input is strict JSON. Do not use JavaScript eval to test input: parsing should treat the candidate as data, not executable code.

How to detect Base64 or Base64url

First decide which variant the surrounding format expects. Standard Base64 and Base64url use different alphabets; Base64url is a distinct encoding variant, not simply a name for any string that looks encoded. RFC 4648 also covers padding, non-alphabet characters, and canonical encodings. See RFC 4648.

  1. Check the candidate against the expected alphabet and the padding rules for that context.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  2. Decode it with a decoder for that specific variant.

  3. Inspect the resulting bytes. Determine whether they make sense for the expected content type; do not assume they are text.

A valid alphabet or successful decode is not proof of intent. Ordinary text can happen to use characters that fit an encoding alphabet, and a decoder’s tolerance for missing padding or other deviations may depend on its implementation. Treat decoding as evidence to assess alongside the field and application context.

How to check whether a string is a URL or URI

Use a URI parser and inspect the components it identifies: scheme, authority, path, query, and fragment. Do not require every candidate to begin with http. URI syntax includes relative references as well as absolute identifiers; RFC 3986 describes the generic syntax. See RFC 3986.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

After parsing, apply the constraints of the scheme and the application. A parseable URI reference is not necessarily an absolute web URL, and syntactic validity says nothing about whether a host resolves, a server responds, access is authorized, or the resource exists. When an application needs those facts, they require separate checks; a syntax parser cannot establish them. The JSON Schema Validation guidance also treats format validation as a distinct concern.

How to identify a timestamp

Prefer a named format with enough information to identify the intended time, such as an RFC 3339 date-time containing a date, time, and UTC offset. Validate the calendar and time fields as well as the offset; matching a rough pattern is not enough. See RFC 3339, which is updated by RFC 9557.

A bare integer may be a timestamp, identifier, or ordinary quantity. Its digit count alone cannot reliably tell you whether it represents seconds or milliseconds. Likewise, a local date-time without a known offset may not identify one unique instant. Use the field definition or application convention to resolve those questions; do not silently infer a unit or timezone.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When a string matches more than one format

Loose checks can overlap. Rank candidate interpretations using the expected field or content type, the required alphabet or scheme variant, and whether the result makes sense without adding assumptions. For example, a successful Base64 decode matters more when the field is documented as encoded binary data than when the same characters appear in an arbitrary label.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.