RGB24 to BGR15 converter

Paste a 6 digit hex color here (XXXXXX) to convert it to the closest BGR15 code. Original idea taken from here and built in JS instead of PHP. You can also enter a 4 digit BGR15 color to decode it back to RGB24.
While input type is RGB24, the foreground is set to the quantized value while background is set to the original, showing any visible color difference to expect.